Hi guys,
Please help point out what’s wrong with my code. Thanks.
I use below code to verify dhtmlxGrid load standard json format. But the result show as below:
1) There are 3 rows in grid. It is correct.
2) grid[0]0] = 1, grid[1][0] = 2, grid[2][0] = 3. Column 0 shows correct values.
3) The remained columns don’t have value. This is incorrect. I don’t know why.
4) There is no exception during parsing json.
By the way, below page states clearly v3.5 supports standard JSON format. docs.dhtmlx.com/doku.php?id=dhtm … _templates
<script type="text/javascript">
var mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../dhtmlx/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("id, userAddress, userAge, userName");
mygrid.setColumnIds("id, userAddress, userAge, userName");
mygrid.setInitWidths("70, 200, 200, *");
mygrid.setColAlign("right,right,right,right");
mygrid.setColTypes("ro,ed,ed,ed");
mygrid.setColSorting("int,str,int,str");
mygrid.setSkin("dhx_skyblue");
mygrid.init();
mygrid.clearAll();
var data = {
"total_count" : 3,
"pos" : 0,
"data" : [ {
"id" : 1,
"userAddress" : "beijing",
"userAge" : 31,
"userName" : "mike"
}, {
"id" : 2,
"userAddress" : "guangzhou",
"userAge" : 32,
"userName" : "liu"
}, {
"id" : 3,
"userAddress" : "shanghai",
"userAge" : 30,
"userName" : "andy"
} ]
};
try {
mygrid.parse(data, "js");
} catch (exception) {
alert("parse json exception.");
}
</script>