Posts Tagged json

json & dojo

After searching through the entire dojo site and documentation finally I found the example about how to pass json object to dojo grid. Actually the solution was in front of my eyes, in the dojox grid examples directory of dojo-1.0.2 release. Here is the solution :
format of the json data must be in this way :

jsonData={ identifier: 'name',  label: 'name',
items: [
{ name:'Nairobi', type:'city' },
{ name:'Mombasa', type:'city' }
]
};
var store = new dojo.data.ItemFileReadStore({data:jsonData});
//to initialize the model object DojoData has to be used, rather than using Table
//query parameter is used to make a query in the given store data. default is also name:'*'.
var myModel = new dojox.grid.data.DojoData(null, store, {
rowsPerPage: 5,
query: {name:'*'}
});
//assuming myGrid object has been initialized with the desired layout
myGrid.setModel(myModel);
myGrid.refresh();

Somehow dojo.data.ItemFileReadStore needs identifier and name parameters in order to parse json data.

Afterall I ‘m not satisfied with the performance of dojo grid. it really takes time to load the libraries and also parsing the json data seems to be time consuming.

Leave a Comment