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
}
Re: Can't set default values for fields
Posted: Wed Jun 12, 2024 9:01 am
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?
Re: Can't set default values for fields
Posted: Wed Jun 12, 2024 9:07 am
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.
Re: Can't set default values for fields
Posted: Wed Jun 12, 2024 11:13 am
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' }
];
}
}