Populating DOJO dropdown list based on JSON Data:
<select data-dojo-type=dijit.form.Select data-dojo-props='name:"dcDistcode"' missingMessage="Enter the Distict code" style="width: 180px" id="dcDistcode"></select>var data ={"identifier":"value","items":[],"label":"distcode"};
var len = newContent.length;
data.items.push(dojo.mixin({"distcode": "--SELECT--"},{"value": ""}));
for(var i=0; i < len ; ++i){
data.items.push(dojo.mixin({"distcode": newContent[i].dcDistcode+' - '+newContent[i].dcDistname},{"value": newContent[i].dcDistcode}));
}
var distStore = dojo.data.ItemFileReadStore({data: data});
dijit.byId("dcDistcode").setStore(distStore);
identifier specifies the value for the drop down list, label specifies the display label for the drop down list.
newContent is the JSON data received from the server.
No comments:
Post a Comment