Dynamic richselect?

I have a editform setup like this:

scheduler.config.form = [
{view:“richselect”,id:“select”,label:scheduler.locale.labels.label_event, options:[{id:“1”,value:“option 1”}]},
{view:“datetext”, label:scheduler.locale.labels.label_start, id:‘start_date’,name:‘start_date’, dateFormat:scheduler.config.form_date},
{view:“datetext”, label:scheduler.locale.labels.label_end, id:‘end_date’,name:‘end_date’, dateFormat:scheduler.config.form_date},
{view:“toggle”, id:‘allDay’, label:"", options: [{value:“0”,label:scheduler.locale.labels.label_time},{value:“1”,label:scheduler.locale.labels.label_allday}], align: “right”,value:“0”},
{view:“textarea”,id:‘details’,label:“Notes”,name:‘details’}
];

Now when the editform is shown I would like to add options to the richselect in the form (for instance { value:2, value:“option 2” }).

I’ve tried the following syntax:

$$(“scheduler”).$$(“editForm”).elements[“select”].attachEvent(“onAfterRender”,function(){
var options = [{id:“1”,value:“option 1”},{id:“2”,value:“option 2”}];
var list = $$(“scheduler”).$$(“editForm”).elements[“select”].getList();
list.parse(options);
});

But “list” is always null. How can I fix this? Am I calling getList() at a wrong time?

Hello,

try to call getList from dhx.delay method:

$$("scheduler").$$("editForm").elements["select"].attachEvent("onAfterRender",function(){ dhx.delay(function(){ var options = [{id:"1",value:"option 1"},{id:"2",value:"option 2"}]; var list = $$("scheduler").$$("editForm").elements["select"].getList(); list.parse(options); }) });