Problematic usage of Json a.rows is undefined

I think it is not the best, that it is always a problem to handle normal standard Json things with DHX.
I try since 4 Days to fill a simple grid with a Json string, which is formatted in exactly the way you provide in your different samples.

  {"rows": [{"cat_id":"4","image":"4.jpg","parent_id":"0","status":true"}]}    

this is the grid:

catgrid = new dhtmlXGridObject('catgrid'); catgrid.setImagePath("{$tpl_path}codebase/imgs/"); catgrid.setHeader("cat_id, image, parent_id, status"); catgrid.setColumnIds("cat_id, image, status"); catgrid.setSkin("dhx_skyblue"); catgrid.init();

I have a tree, too. On select a tree item theres a function call:

[code] function get_cat_data(id){
var loader=dhtmlxAjax.postSync(“includes/modules/admin/process.php”, ‘action=catdata&catid=’+id);
catgrid.clearAll();

    var catdata  = JSON.parse(loader.xmlDoc.responseText);
    catgrid.parse(catdata,"json");

}[/code]

The results is: TypeError: a.rows is undefined

I tried out some of the methods to load or parse the loader data, but all the time without any success. It is so, that I test the DHX since a week and came to opinion, that it is to expensive to buy the professional Version if you have 3 timekilling issues in a week when you just try to follow the documentation and samples by yourself. Maybe I wait until you developed usable Json support for every module. Ajax ist state of the art and Json is the serialisation method for AJAX you know.

Shouldn’t it work that way? This is, what the documentation means. But it don’t. What now? It is not possible for my application to deal with a converting class to XML because of performance decrease.
Can anybody tell me, what exactly works around my issue above?
Or where the mistake is? Would be nice to get an answer.
Because I wait and can’t go on at the moment. Thx

Thank you for the great support :confused: :frowning:

Default data loading expect a different json structure.
docs.dhtmlx.com/doku.php?id=dhtm … _from_json

But if you are using the latest 3.6 build, just change the code like next
catgrid.parse(catdata,“js”); //js not json

and you will be able to use data similar to one in your case

{"data": [{"cat_id":"4","image":"4.jpg","parent_id":"0","status":true"}]}   

or

[{"cat_id":"4","image":"4.jpg","parent_id":"0","status":true"}]

This one works so far, that I find the result well formatted in the callback.
But the data will not display in the specific culumns.
Only the “cat_id” displays. I want to have each value in the correct row. Is it possible anyhow to influence this?

my callback result: [{“cat_id”:“4”,“image”:“4.jpg”,“parent_id”:“0”,“status”:true"}]

        catgrid.setHeader("cat_id, image, parent_id, status");
        catgrid.setColumnIds("cat_id, image, parent_id, status");

my output:
cat_id image parent_id status
4 empty empty empty (empty means, no value displayed)

Please, try to remove spaces before the id of the column:
catgrid.setColumnIds(“cat_id,image,parent_id,status”);
instead of
catgrid.setColumnIds(“cat_id, image, parent_id, status”);

Wonderful :slight_smile: