Our pure JavaScript Scheduler component


Post by plo »

Hello,

I have a problem to set default values when creating new event in the Scheduler taskEdit. This is for the fields statusField, effortField and typeField. I tried to set "value", "magnitude", "defaultValue" etc. and it does not seem to work?

statusField: {
								type : 'combo',
								name : 'status',
								label : 'Status',
								weight: 5,
								required: true,
								items : task_status,
								valueField : 'id',
								displayField : 'text',
								editable: false,
								clearable: false
							},
							effortField : {
								label: 'Timer',
								weight: 6,
								allowNegative: false
							},
							typeField: {
								type : 'combo',
								name : 'type',
								label : 'Type',
								weight: 7,
								required: true,
								items : [
									{ id : 'task', text : 'Opgave' },
									{ id : 'internal_time', text : 'Intern tid' },
									{ id : 'holiday', text : 'Ferie/sygdom' },
									{ id : 'reserved', text : 'Reserveret' }
								],
								valueField : 'id',
								displayField : 'text',
								editable: false,
								clearable: false
							}
Attachments
Screenshot_33.png
Screenshot_33.png (25.38 KiB) Viewed 196 times

Post by Animal »

I'm confused as to what you are wanting to do, and how you are trying to do it.

Those aded field definitions look OK.

So what do you need to happen, and what code have you added and where to try to make that happen?


Post by plo »

Hello Animal,
What I need to happen is that when I double click in the scheduler view, the taskEdit popup - where i can write in the info for the new event - has fields where there are no default values. Example, I want the statusField to always select the first value as default, because right now it's always empty? As I wrote, I have tried to set "value", "defaultValue" etc. without luck.


Post by mats »

As this is loaded from the EventRecord each time the editor is opened, it's better to set your default values in your custom EventModel class.

class MyEvent extends EventModel {
    static get fields() {
        return [
            { name : 'status', defaultValue : 'foo' },
            { name : 'type', defaultValue : 'bar' }
        ];
    }
}

And then configure your event store to use it:

const scheduler = new Scheduler({
    appendTo: 'container',
   
eventStore : { modelClass : MyEvent },

Post by plo »

Hi mats,
Thank you! It's working now :)


Post Reply