Grid/Column Structure in JSON for TreeGrid+Branch Expansion

Hi,

I’m trying to use DHX 3.0 Pro with as much JSON as possible since it’s more efficient as far as JavcaScript and network. I could not find anywhere mentioning of how to set up the columns for the grid in JSON. Looking at the source code, it would seem like it is possible in XML only.
Would that be possible in JSON?
In our case we resorted to defining the columns in an XML response and the data load of the rows is using JSON. The problem is once we did that the kidsXmlFile call is using the XML instead of JSON (Remember we want the data retrieval at least to be in JSON). We had to forcefully change the call to use JSON instead.

Finally, once we tweaked that and got the correct parser to respond to the tree expansion in JSON, we tried to enable smart rendering.
It seems like when we first call the API to set up the columns(Remember, the only way was in XML), it initialized the _fillers structure that was never updated for the latter JSON data call. As a result the grid comes up empty if enabling smart rendering.

-Gabriel

Here is the example of configuring the grid’s columns from JSON:

[code]data={
“parent”:“gridbox”,
“image_path”:"…/…/codebase/imgs/",
“editable”:true,
“multiselect”:true,
“autowidth”:true,

“columns”:[{
“label”:“Node”,
“id”:“name”,
“width”:80,
“align”:“right”,
“sort”:“str”,
“type”:“ed”
},
{
“label”:“X-coord”,
“id”:“xcoord”,
“width”:140,
“align”:“right”,
“sort”:“int”,
“type”:“edn”
},
{
“label”:“Y-coord”,
“id”:“ycoord”,
“width”:140,
“align”:“right”,
“sort”:“int”,
“type”:“edn”
},
{
“label”:“Z-coord”,
“id”:“zcoord”,
“width”:140,
“align”:“right”,
“sort”:“int”,
“type”:“edn”
},
{
“label”:“Comment”,
“id”:“comment”,
“width”:250,
“align”:“left”,
“sort”:“str”,
“type”:“ed”
}
]
}

data1={
“pos”:0,
“total_count”:2,
“rows”:[{
“id”:1,
“data”:[“S1-A1”,
“0”,
“0”,
“0”,
“Story 1, Grid A/1”
]
},
{
“id”:2,
“data”:[“S1-A2”,
“0”,
“15”,
“0”,
“Story 1, Grid A/2”
]
}]}

mygrid = new dhtmlXGridObject(data);
mygrid.setImagePath(“codebase/imgs/”);
mygrid.preventIECaching(true);
mygrid.enableSmartRendering(true,50);
mygrid.setNumberFormat(“00,000.000”,1,".",",");
mygrid.setNumberFormat(“00,000.000”,2,".",",");
mygrid.setNumberFormat(“00,000.000”,3,".",",");
mygrid.setSkin(“web”);
mygrid.parse(data1,“json”)[/code]

Hi,

I’m loading the JSON from the server. Will the JSON gird config work with the treegrid.load method?
Also, it would seem like on expansion of a branch in the TreeGrid its expecting an XML. Will the parsing of the branch expansion handle JSON?

Thanks
Gabriel

Unfortunately it’s not available to configure the grid from JSON file.
I recommend you to use XML format of data. It has more possibilities to suit your requirements.