Dojo how to get JSON attribute from dojo.data.ItemFileReadStore

I have the following JSON in the typeData variable, which is then placed in the dojo.data.ItemFileReadStore repository. I need to know how to check the status value, whether it was set to β€œsuccess” or some other value. I was not able to figure out how to get the status value from ItemFileReadStore, any help would be greatly appreciated.

var typesData = { status: "success", label: "name", identifier: "value", items: [ {value: 3, name: "Truck"}, {value: 8, name: "Van"}, {value: 6, name: "Car"}, {value: 7, name: "Scooter"} ] }; var test = new dojo.data.ItemFileReadStore({ data: typesData }); 
+4
source share
1 answer

ItemFileReadStore will not handle additional data object attributes. However, you can extend the ItemFileReadStore to do what you need. You will override the "internal" methods, so the developer should beware.

 dojo.declare("MyCustomStore", [Store], { _getItemsFromLoadedData: function(/* Object */ dataObject){ this.serverStatus = dataObject.status; this.inherited(arguments); } }); var typesData = { status: "success", label: "name", identifier: "value", items: [ {value: 3, name: "Truck"}, {value: 8, name: "Van"}, {value: 6, name: "Car"}, {value: 7, name: "Scooter"} ] }; var test = new MyCustomStore({ data: typesData }); test._forceLoad(); // forces the processing of the data object console.debug(test.serverStatus); 

http://jsfiddle.net/cswing/dVGSc/

+4
source

All Articles