Hey, I'm having a hard time finding an example of how to make a grid display a JSON object that I am receiving from my server. If anyone knows of any or has experience with this that would be greatly appreciated. Thanks!
Hey, I'm having a hard time finding an example of how to make a grid display a JSON object that I am receiving from my server. If anyone knows of any or has experience with this that would be greatly appreciated. Thanks!
here's an example
dojo.addOnLoad(function(){
var view1 = {
cells: [[
{name: 'Name', field: "name", cellStyles: "color:blue;"},
{name: 'Address', field: "address", cellStyles: "color:purple;"},
{name: 'Pay Scale', field: "pscale", cellStyles: "color:blue"}
]]
};
var fixedColumn = {
noscroll: true,
cells: [[ {name: 'Employee #", field: "empno", cellStyles: "color:purple;" } ]]
};
// a grid layout is an array of views.
var layout = [ fixedColumn, view1 ];
var store1 = new dojo.data.ItemFileReadStore({jsId: 'jsonStore', url: 'getEmployeeServlet'});
var model = new dojox.grid.data.DojoData(null,null,
{jsId: 'model',
store: store1,
rowsPerPage: 20,
query: { empno: '*' },
sortFields : [{attribute: 'empno', ascending: true}]
});
grid = new dojox.Grid({id: "srGrid", structure: layout, model: model,elasticview:"2"},dojo.byId("gridContainer"));
})
where:
1. gridContainer is a div in your html
2. getEmployeeServlet is a servlet that output a json formatted http response
hope that helps