updateFromXML JSON versin?

updateFromXML is a great function and works amazingly well.

I populate grids mostly using JSON and need updateFormJson(). Is there such a function?

Please, try to use:

mygrid._refresh_mode=[url, insert_new, del_missed, afterCall]; // parameters the same as in the updateFromXML() method mygrid.load(url,"json")

Suppose I have the data already, is there a way to update only the changed cells / rows?

Is there a function in which I can pass the data similar to grid.parse() and it would update the grid?

Or do I need to grid.clearAll() and gird.parse() with each change?

Please, try to use:

mygrid._refresh_mode=[url, insert_new, del_missed, afterCall]; // parameters the same as in the updateFromXML() method mygrid.parse(data,"json")

In: mygrid._refresh_mode=[url, insert_new, del_missed, afterCall]

would the url be ‘’ or undefined or null?

Shame! :blush: I apologize for my inattention!
It’s my mistake.
_refresh_mode function does not require the “url” attribute.

mygrid._refresh_mode=[insert_new, del_missed, afterCall]; // the parameters are the same as in the updateFromXML() method mygrid.parse(data,"json")

I can’t get this work:

      ppNew.grid._refresh_mode=[true, true, function(){}]; 
      ppNew.grid.parse(r.data, "json");

whereas, a standard parse does work, so I do not think it is a problem with the data:

      ppNew.grid.parseJs(r.data, "json");

I am attaching a screenshot of the error and the data:


Please, refer to the supported “json” format of data:
docs.dhtmlx.com/grid__data_forma … jsonformat

May be, you may try to use the “js” type.

I tried “js” type and that fails too:

ppSearch.grid._refresh_mode=[true, true, function(){}]; 
ppSearch.grid.parse(r.data, "js");

If the problem still occurs for you please, provide with the sample of your code with the init of your grid and the generated json string.

I got busy and was unable to put together a demo so I wound up using parse().

Today I needed to merge rows into a grid so I wrote a prototype:

dhtmlXGridObject.prototype.mergeJs = function(js, updateCells){	
  var r, c, a;
  for (r=0; r < js.total_count; r++){
    if (this.getRowIndex(js.data[r].id) == -1) {
      a = [];  
      for (c=0; c<this.getColumnsNum(); c++){
        a.push( js.data[r][this.getColumnId(c)])
      }
      this.addRow(js.data[r].id, a)
    }
  }
}

As time permits and when I actually need it, I’ll turn this into a method which will intelligently update the existing columns and delete rows when specified.