Search code examples
javascriptdhtmlx

dhtmlxgrid - load ( url ) for changing data set


I am using dhtmlxgrid and calling the function

mygrid.load ( url, "json" ) . 

The url points to a file which has the data shown below.

The data returned by the url is of format

data = {
rows: [{
    id: 1001,
    data: ["200", "The Rainmaker", "John Grisham", "101", "0" ]
    }, {
    id: 1002,
    data: ["1002", "A Time to Kill", "John", "90", "110" ]
    }]
}

This mygrid.load is called repeatedly in loop every few seconds.

The first time, the data is correctly loaded in the mygrid. The next times also when the data is changed, it's correctly updated in the grid.

The problem is that the new records and deletes are not seen on the grid. Any idea how this method can be done in this method.

I am trying to find something equivalent of mygrid.updateFromXML - but for json with insert/deletes.

http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:api_method_dhtmlxgridobject_updatefromxml ( but for json )


Solution

  • To reload data you need to use something like next

    grid.clearAll(); //clear old data first
    grid.load(url, "json");