The key point here is that you need to convert the data first before using them in the dojo grid.
A live demo can be found here .
dojo.require("dojox.grid.DataGrid"); dojo.require("dojo.data.ItemFileReadStore"); dojo.addOnLoad(function() { var data = { "head": { "vars": [ "s" , "fname" , "lname" ] } , "results": { "bindings": [ { "s": { "type": "uri" , "value": "http://tn.gov.in/Person/41" } , "fname": { "type": "literal" , "value": "Gayathri" } , "lname": { "type": "literal" , "value": "Vasudevan" } } , { "s": { "type": "uri" , "value": "http://tn.gov.in/Person/37" } , "fname": { "type": "literal" , "value": "Magesh" } , "lname": { "type": "literal" , "value": "Vasudevan" } } , { "s": { "type": "uri" , "value": "http://tn.gov.in/Person/39" } , "fname": { "type": "literal" , "value": "Vasudevan " } , "lname": { "type": "literal" , "value": "Srinivasan" } } ] } }; var items = dojo.map(data.results.bindings, function(binding) { return {fname : binding.fname.value, lname : binding.lname.value}; }); var store = new dojo.data.ItemFileReadStore({ data : { items : items } }); _createGrid(store); function _createGrid(store) { var layout = _getGridLayout(), node = dojo.create("div", {}, dojo.byId("grid"), "only"); var grid = new dojox.grid.DataGrid({ store : store, structure : layout, rowsPerPage: 10 }, node); grid.update(); grid.startup(); return grid; } function _getGridLayout() { return [[ { field : "fname", name : "First Name", width : "50%"}, { field : "lname", name : "Last Name", width : "50%" } ]]; } });
source share