Our pure JavaScript Scheduler component


Post by SergeyByslyuk »

Can i customize a custom editor by resource or another type? I found in the examples the following option for setting the editor by name in the "dataset" field:

eventEdit: {
    items: {
        eventTypeField: {
            type: 'combo',
            name: 'eventType',
            label: 'Type',
            weight: 110,
            items: ['Appointment', 'Internal', 'Meeting']
        },
        locationField: {
            type: 'text',
            name: 'location',
            label: 'Location',
            weight: 120,
            // This field is only displayed for meetings
            dataset: {
                eventType: 'Meeting'
            }
            
} ... } }

.


Post by pmiklashevich »

Using eventType is not a good approach. We have a ticket to deprecate it.
https://github.com/bryntum/support/issues/2009

Please add a change listener on the resource field and update visibility of the fields your want. For example, you can try this code in Basic demo:

const scheduler = new Scheduler({
            features: {
                eventEdit: {
                    typeField: 'resourceId',
                    items: {
                        locationField: {
                            type: 'text',
                            name: 'location',
                            label: 'Location',
                            weight: 120
                        }
                    }
                }
            },
            listeners: {
                beforeEventEditShow: ({
                    editor
                }) => {
                    const {
                        resourceField,
                        locationField
                    } = editor.widgetMap;
                    
if (resourceField && !resourceField.__changeListener) { resourceField.__changeListener = resourceField.on({ change: ({ value }) => { // Only Don has Location field locationField.hidden = value !== 'r3'; } }); } } },

https://www.bryntum.com/docs/scheduler/#Core/widget/Combo#event-change
https://www.bryntum.com/docs/scheduler/#Core/widget/Combo#property-hidden

Best,
Pavel

Pavel Miklashevich - Core Developer

Post Reply