Search code examples
javascriptdojodojox.griddojox.grid.datagrid

How to Update dojo grid using json object?


Can some one pls tell me how to update data grid using a json object. My data grid is created as beleow.

var grid4 = new dojox.grid.DataGrid({
                    query : {
                        number: '*'
                    },
                    clientSort : true,
                    rowSelector : '20px',
                    structure : layout4
                }, document.createElement('div'));
        grid4.setStore(jsonStore);
        dojo.byId("gridContainer4").appendChild(grid4.domNode);
        grid4.startup();

initially jsonStore applies to the grid without any problem. But later I get json object something similar to following.

data = {
            "results" : {
                "info" : [{
                            "number" : "12.11",
                            "product" : "KALA,
                            "Qty" : "0.00" }]
            }
        }

So I need to apply these data to my grid. I dont know how to do it can some one plese help me to data. Thanks in advance.


Solution

  • The store should contain the "data" key, as you correctly did, and the corresponding object should have the "items" key. Have a look also at my answer here: Dojo grid nested json