In a Standalone Editor is it possible to use the options (for a select control) from the data source
In a Standalone Editor is it possible to use the options (for a select control) from the data source
brendons
Posts: 39Questions: 14Answers: 1
I am populating a standalone editor from ajax which returns the data for advisorId:
editor.edit(ID, false).set('est.AdvisorID', advisorId).buttons({label: "Save", ...}).open();
This field is a select input and the keys:values come from options in the datasource.
Field::inst('est.AdvisorID')
->options( Options::inst()
->table('(SELECT ID, AdvisorFirstName, AdvisorLastName
FROM enrollment_advisors
WHERE AdvisorArchived = 0) as T1')
->value('T1.ID')
->label(array('T1.AdvisorFirstName', 'T1.AdvisorLastName'))
)
->setFormatter( 'Format::nullEmpty' )
->getFormatter( 'Format::nullEmpty' ),
In a normal editor (that is attached to a table) this works fine, but for this standalone editor, is it possible to pass the key:value pairs from the options to the standalone editor field? If not, is there another way?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The way it works in a DataTables connected Editor is that Editor listens for the
xhr
event when DataTables loads data. Editor will then search for the options and populate the list if found.Since there is no Ajax event to listen for in a standalone Editor, what you need to do is make the Ajax call to get the options yourself and then use the
update
method of theselect
field type to populate the options.Allan
set the options for a standalone editor select field:
Thanks to Allan for showing me how to do this.