Grid Data: a 3rd JSON format


#1

Grid’s Basic JSON format is great because it reduces the amount of data transmitted through the network:

data={ rows:[ { id:1, data: ["A Time to Kill", "John Grisham", "100"]}, { id:2, data: ["Blood and Smoke", "Stephen King", "1000"]}, { id:3, data: ["The Rainmaker", "John Grisham", "-200"]} ] };

Grid’s Native format is great because the column order in the grid definition can change without needing to change the server-side code and you always know that the correct data will land in the correct column every time:

data= {"total_count":50000, "pos":0, "data":[
  { "title": "A Time to Kill",
    "author": "John Grisham",
    "price": "100"
  }}

What we need is a third format which combines the best of both:

data={ colDataIds:{"title","author","price"} rows:[ { id:1, data: ["A Time to Kill", "John Grisham", "100"]}, { id:2, data: ["Blood and Smoke", "Stephen King", "1000"]}, { id:3, data: ["The Rainmaker", "John Grisham", "-200"]} ] };

And then in the grid definition, the column order could be set as needed:

mygrid = new dhtmlXGridObject('gridbox');
mygrid.setColumnIds("title","author","price");

Or if you wanted Author then Title:

mygrid = new dhtmlXGridObject('gridbox');
mygrid.setColumnIds(""author",title","price");

#2

It is possible to add a custom JSON data parser
docs.dhtmlx.com/grid__data_forma … dataformat

Also, you can contact sales@dhtmlx.com about the customization.