dynamic - How to dynamically add elements to a Dojo ComboBox -
i have dojo combobox declaratively created using standard html select. there onchange event on separate textbox invokes function data server via xhr , elements of response data become new options drop down.
i've been trying examples across internet nothing far has worked. code i'm trying no errors. in fact, when @ contents of store after put, data in there.
when click on drop down after data has been set, error "_autocompletermixin.js.uncompressed.js:557 uncaught typeerror: cannot read property 'tostring' of undefined":
var newoptions = new array(); (var = 0; < jsondata.length; i++) { newoptions[i] = { value: jsondata[i].dataid, label: jsondata[i].dataname, selected: == 0}; } var select = registry.byid("combobox"); select.store.put(newoptions, { overwrite: true });
and "select.store.data = newoptions;". , moving code around "select.store.add(option)" within loop.
though combobox store being populated in 3 cases, continue same error. there no null values in data. there no blank values in data.
what missing? no example anywhere, within dojo docs or anywhere else has problem, working jsfiddle examples.
i cannot see difference other fact i'm adding more 1 or 2 hard-coded values.
it takes:
newoptions[i] = { id: jsondata[i].dataid, name: jsondata[i].dataname, selected: == 0};
not
newoptions[i] = { value: jsondata[i].dataid, label: jsondata[i].dataname, selected: == 0};
Comments
Post a Comment