Editor DropDowns Not Working
Editor DropDowns Not Working

Probably doing something wrong on a very basic level here, but I'm trying to just get the results of an API call to populate a DataTable and editor drop-downs populated. The data loads just fine but I can't get values in the drop-down.
JSON Snippet:
{
"data":[]
,"draw":"1"
,"recordsFiltered":0
,"recordsTotal":0
,"options":[
{"itemNo":[
{"id":"123","name":"PC2011"}
,{"id":"234","name":"PC2012"}
,{"id":"345","name":"RA0170"}
,{"id":"456","name":"RG3042"}
,{"id":"567","name":"RV2050"}
]}
,{"loc":[
{"id":"BRW","name":"Brodhead WH"}
,{"id":"FBP","name":"Bethlehem"}
,{"id":"FIC","name":"Innovation Ctr"}
,{"id":"GTP","name":"Godshalls"}
]}
]
}
Relevant Area of Editor:
...
fields: [{
label: "Item Number:",
name: "itemNo",
type: "select",
optionsPair: {
label: "itemNo.name",
value: "itemNo.id"
}
}, {
label: "From Location:",
name: "fromLoc"
}, {
label: "To Location:",
name: "toLoc"
}, {
label: "Quantity:",
name: "remaining"
}]
...
This has got to be something very simple I'm missing, anybody spot it?
This discussion has been closed.
Answers
Hi @aatkins ,
This thread should help, it's asking the same thing.
Cheers,
Colin
I saw that thread, but my JSON looks almost exactly like Allan's answer and it still doesn't work. The thread also ends without displaying the final resolution (was taken offline). Still need help and don't understand why my code doesn't work.
Change:
to be:
It already knows to use
itemNo
from the field name.Allan
Thanks Allan, that's what I thought at first as well, but it doesn't work, still an empty drop-down.Below is JSON stream with actual data if it helps at all. I seriously don;t get why this is not working...
Changing the editor to this did not show anything in the dropdown when clicking the "Add Item" button:
Still don't know why it won't work the way above, but I managed to break out the ajax call into an object and parse the options into two arrays, which then successfully worked with the update() function:
I'm thinking maybe the JSON is nested too deep, as I needed two loops to get at the options for the dropdown:
I'm calling a custom API to generate the object in the first place, must have not gotten something right on the back end to make it an extra layer deep. Regardless, it's working now, if not round-about (it so happens I need to maintain the data sources outside of the grids anyway, so win-win).