The JSON parsing is not working completely for me
I tried this :
[code]var jsonObj = new Object();
jsonObj.total_count = 100;
jsonObj.pos = 0;
jsonObj.rows = [];
var r = new Object(); r.data = ["a", "b"]; jsonObj.rows.push(r);
mygrid.parse(jsonObj,"json");
[/code]
And the grid shows me the first row.However , if try to add another row, it still shows me only the first row, meaning only the first row gets parsed.
[code]var jsonObj = new Object();
jsonObj.total_count = 100;
jsonObj.pos = 0;
jsonObj.rows = [];
var r = new Object(); r.data = ["a", "b"]; jsonObj.rows.push(r);
r = new Object(); r.data = ["c", "d"]; jsonObj.rows.push(r);
mygrid.parse(jsonObj,"json");
[/code]
I am not able to upload the file . So here is the code in sample.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>For demo purpose only :: &1</title>
<link rel='STYLESHEET' type='text/css' href='codebase/dhtmlxgrid.css'>
<link rel='STYLESHEET' type='text/css' href='codebase/skin/dhtmlxgrid_dhx_skyblue.css'>
<script src='codebase/dhtmlxcommon.js'></script>
<script src='codebase/dhtmlxgrid.js'></script>
<script src='codebase/dhtmlxgrid_json.js'></script>
<script src='codebase/dhtmlxgridcell.js'></script>
</head>
<body>
<h1>Configuration from XML</h1>
<p>Configuration of grid can be loaded from XML file. You need only 2-3 script commands to get the grid up and running.</p>
<div id="gridbox" style="width:600px; height:270px; background-color:white;"></div>
<a href='#alfa' onClick="if(mygrid.setSerializationLevel){ser();} else {alert('Available in Pro Edition only')}">Serialize grid</a>
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath('codebase/imgs/');
mygrid.setSkin("dhx_skyblue")
mygrid.setHeader("A,B")
mygrid.setInitWidths("100,100");
mygrid.init();
mygrid.attachEvent("onDynXLS", function(pos, count){
alert("Extra data request");
return false;
});
mygrid.xmlFileUrl = "dummy";
var jsonObj = new Object();
jsonObj.total_count = 100;
jsonObj.pos = 0;
jsonObj.rows = [];
var r = new Object(); r.data = ["a", "b"]; jsonObj.rows.push(r);
r = new Object(); r.data = ["c", "d"]; jsonObj.rows.push(r);
//alert("Set the rows JSON");
/*
[{
data: ["a", "b"]
}, {data:["c", "d"]}
];
*/
/*
mygrid.parse({
total_count:100,
pos:0,
rows:[["a","b"],[["c","d"]]]
},"json");
*/
mygrid.parse(jsonObj,"json");
</script>
<a name="alfa">
<div id="alfa1"></div>
</a>
</body>
</html>
Also, there is no call to
grid.enableSmartRendering()
How does the grid know to fetch rows from the server and also the count of new rows to be fetched ?