so, to confirm, there is no attribute "selected" on the particular items in ipOpts and it requires jquery or other code to achieve this in the DataTables/Editor form.
To clarify my original question, is there an attribute of the ipOpts items that caused that item to be selected when the SelectList is rendered.
If the original question, I want January, February, March, and April all to be rendered as selected, and I want to do it with the ipOpts data alone.
You are correct - there is no selected parameter for the options of a select input. The selected value will either come from the row being edited or the field's default value (field.def). For that reason a selected parameter would never actually get used!
If you want some values to be preselected on create, do so with the field default.
Answers
oops, hit enter too quickly.
referring to this other question: https://datatables.net/forums/discussion/19579
If I want some of the months to be selected, I find that the following attempts do not work:
"ipOpts": [
{ "label": "January", "value": "jan", attr: {selected:true}},
{ "label": "February", "value": "feb" , selected:true },
{ "label": "March", "value": "mar" , "selected":"true" },
{ "label": "April", "value": "aprl" , "checked":"1" },
{ "label": "May", "value": "may" },
{ "label": "June", "value": "jun" },
{ "label": "July", "value": "jul" },
{ "label": "August", "value": "aug" },
{ "label": "September", "value": "sept" },
{ "label": "October", "value": "oct" },
{ "label": "November", "value": "nov" },
{ "label": "December", "value": "dec" }
]
What is the syntax to cause an option to render as "selected" when the select list is dropped?
Start with this SO thread. There are others that show ways of doing this. If you still need help then create a simple test case showing what you have and what you want to do so we can offer suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
so, to confirm, there is no attribute "selected" on the particular items in ipOpts and it requires jquery or other code to achieve this in the DataTables/Editor form.
To clarify my original question, is there an attribute of the ipOpts items that caused that item to be selected when the SelectList is rendered.
If the original question, I want January, February, March, and April all to be rendered as selected, and I want to do it with the ipOpts data alone.
You are correct - there is no
selected
parameter for the options of aselect
input. The selected value will either come from the row being edited or the field's default value (field.def
). For that reason aselected
parameter would never actually get used!If you want some values to be preselected on create, do so with the field default.
Allan