Load treegrid from json!

What am I doing wrong? All I get is the wrapper with the proper style, but no treegrid inside:



the json:

{ rows:[ { id:'1001', data:[ {"value":"row A","image":"folder.gif"}, "A Time to Kill", "John Grisham", "12.99", "1", "05/01/1998"], rows:[ { id:'sub_1001', data:[ "subrowA", "Blood and Smoke", "Stephen King", "0", "1", "01/01/2000" ] }, { id:'sub_1002', data:[ "subrowB", "Blood and Smoke", "Stephen King", "0", "1", "01/01/2000"] } ] }, { id:'1002', xmlkids:'1', data:[ "row B", "The Green Mile", "Stephen King", "11.10", "1", "01/01/1992"] } ] }

Thnak you!

Your code works well for us but you add “dhtmlxtreegrid_pro.js” to your code which already have all components of dhtmlxGrid inside.
Please, try to remove all other js files to avoid duplicating.
If issue still occurs - please provide a complete demo or a demo link where the issue can be reconstructed.


So I’ve realized that id I ut the json in a js variable like:

data1 = …json…

and then in the treegrid conf I put:


The treegrid load correctly. But then the json code will be visible in the source code of the page.

So how can I load the json from an php file that’s in the same server/folder?

treegrid code:


	div.gridbox div.ftr td{
	div.gridbox table.hdr td {


This load the treegrid with no content :frowning:

Error type: LoadXML
Description: Incorrect JSON

But if I put the json into the variable it loads ok.

plz help

Where the file “dhtmlxtreegrid_pro.js” is located?
I have PRO version (111031) but I have no that file in distribution.
Can it be the problem why I cannot load the treegrid from JSon?

the requested file should be in “dhtmlxgrid/codebase/ext” directory. It s included only in PRO version of dhtmlxgrid component.
It is necessary to add the dhtmlxgrid_json.js for loading data from JSON files.

I have PRO version of 111031 and I don’t have that file in the “dhtmlxGrid\codebase\ext”.
Here is content of that folder:

07/13/2011 03:13 PM .
07/13/2011 03:13 PM …
07/13/2011 03:13 PM 3,542 dhtmlxgrid_data.js
07/13/2011 03:13 PM 15,661 dhtmlxgrid_deprecated.js
07/13/2011 03:13 PM 1,055 dhtmlxgrid_dom.js
07/13/2011 03:13 PM 13,441 dhtmlxgrid_drag.js
07/13/2011 03:13 PM 5,158 dhtmlxgrid_export.js
07/13/2011 03:13 PM 1,048 dhtmlxgrid_fast.js
07/13/2011 03:13 PM 12,563 dhtmlxgrid_filter.js
07/13/2011 03:13 PM 4,023 dhtmlxgrid_form.js
07/13/2011 03:13 PM 11,866 dhtmlxgrid_group.js
07/13/2011 03:13 PM 1,740 dhtmlxgrid_hextra.js
07/13/2011 03:13 PM 151 dhtmlxgrid_hmenu.css
07/13/2011 03:13 PM 3,609 dhtmlxgrid_hmenu.js
07/13/2011 03:13 PM 2,634 dhtmlxgrid_json.js
07/13/2011 03:13 PM 4,286 dhtmlxgrid_keymap_access.js
07/13/2011 03:13 PM 4,607 dhtmlxgrid_keymap_excel.js
07/13/2011 03:13 PM 493 dhtmlxgrid_keymap_extra.js
07/13/2011 03:13 PM 5,561 dhtmlxgrid_lines.js
07/13/2011 03:13 PM 2,865 dhtmlxgrid_markers.js
07/13/2011 03:13 PM 5,303 dhtmlxgrid_math.js
07/13/2011 03:13 PM 8,127 dhtmlxgrid_mcol.js
07/13/2011 03:13 PM 10,337 dhtmlxgrid_nxml.js
07/13/2011 03:13 PM 866 dhtmlxgrid_over.js
07/13/2011 03:13 PM 12,161 dhtmlxgrid_pgn.js
07/13/2011 03:13 PM 3,512 dhtmlxgrid_pgn_bricks.css
07/13/2011 03:13 PM 6,469 dhtmlxgrid_pivot.js
07/13/2011 03:13 PM 678 dhtmlxgrid_post.js
07/13/2011 03:13 PM 15,635 dhtmlxgrid_rowselector.js
07/13/2011 03:13 PM 2,775 dhtmlxgrid_rowspan.js
07/13/2011 03:13 PM 8,688 dhtmlxgrid_selection.js
07/13/2011 03:13 PM 25,912 dhtmlxgrid_splt.js
07/13/2011 03:13 PM 4,465 dhtmlxgrid_srnd.js
07/13/2011 03:13 PM 4,318 dhtmlxgrid_ssc.js
07/13/2011 03:13 PM 3,810 dhtmlxgrid_start.js
07/13/2011 03:13 PM 1,929 dhtmlxgrid_undo.js
07/13/2011 03:13 PM 4,028 dhtmlxgrid_validation.js
07/13/2011 03:13 PM 624 dhtmlx_extdrag.css
07/13/2011 03:13 PM 2,424 dhtmlx_extdrag.js
37 File(s) 216,364 bytes

I also assign the dhtmlxgrid_json but I have a similar exception:

Error type: LoadXML
Description: Incorrect JSON

Can it be possible to provide a working example of how Treegred may be populated with Json? Because the sample only loading the XML as a data source and example of Json data in the documentation seems have some problem with parsing.


Accordingly to the snippet from your first post in that topic:

you add dhtmlxtreegrid_pro.js to your page. So I suggested you NOT to use that compiled file with the others js files.

Later you post:
Where the file “dhtmlxtreegrid_pro.js” is located?
I have PRO version (111031) but I have no that file in distribution.

We have provided you a working demo with the loading treegrid from JSON file.
If issue still occurs - please, send a complete demo where the issue can be reconstructed.

Thanks for the demo. I figure out that the problem is with my Google Chrome what are configured as default browser. When I opening your demo in Chrome - I got the same error:

Error type: LoadXML
Description: Incorrect JSON

For the other browsers, at least IE 9 and Firefox 14.0.1 your example works fine.

I have a Google Chrome version 20.0.1132.57 m - just in case.

Any ideas?

Unfortunately the issue also cannot be reconstructed.
The provided demo works well in Chrome for us (21 ver.)

Please, try to update/reinstall your browser.
Check if the issue occurs on the other PCs or on your machine only.

Can you please check the following code and let me know what’s going wrong?

var jsonStr = ‘{rows:[{id:‘1001’,data:[{“value”:“row A”,“image”:“folder.gif”},“A Time to Kill”,“John Grisham”,“12.99”,“1”,“05/01/1998”],rows:[{id:‘sub_1001’, data:[“subrowA”,“Blood and Smoke”,“Stephen King”,“0”,“1”,“01/01/2000”]},{ id:‘sub_1002’,data:[“subrowB”,“Blood and Smoke”,“Stephen King”,“0”,“1”,“01/01/2000”] }]},{ id:‘1002’,xmlkids:‘1’,data:[“row B”,“The Green Mile”,“Stephen King”,“11.10”,“1”,“01/01/1992”] }]}’;

var csTreeGrid = new dhtmlXGridObject('gridbox');
csTreeGrid.selMultiRows = true;
csTreeGrid.imgURL = conf.staticResourceUrl + "/resources/images/dhtmlx/mettl_folder/";
csTreeGrid.setHeader("Tree,Plain Text,Long Text,Color,Checkbox");
csTreeGrid.parse(jsonStr, "json");

I am using the sample JSON provided on ur site. The following JS files are included:

I am fine with providing the JSON as a data string to the ‘parse’ method. No error is thrown in the above code, but the rows are not rendered.

Any help is appreciated.


Your code works well for us in firefox, Google Chrome, Internet Explorer browsers.

If issue still occurs for you - please, open ticket at support.dhtmlx.com and provide with a complete demo, where the issue can be reproduced locally.