Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by j.lagos on Jan 20, 2009 01:08
open dhtmlx forum
Grid update using JSON

I am using the PRO and JSON to load a Grid progressively, which means:
Loading some data with
mygrid.load(Thread.php+"?date="+fdate,"json");

After a time, successive calls to the same function does not insert new rows into the Grid.
The Thread.php is called, the json string is returned, but the Grid is not updated with new rows.
Is there any trick to overcome this problem?

And 2. Is there a way (event...) to filter before Insert?
Because for some values returned from Thread.php, I want to deside to Insert then into anoather Grid.

Thanks in advance,
John
Answer posted by Support on Jan 20, 2009 06:16
>>Is there any trick to overcome this problem?
The load command used to load all data at once, it not suitable for loading additional data. 
If you known the total count of rows , you can use dyn. smart rendering mode ( works for both json and xml ) , in which you can load initial set of data and additional data will be auto-loaded while scrolling.
( in case of XML - it possible to use updateFromXML - which adds new rows from incoming XML, but there is no json based alternative ) 

>>And 2. Is there a way (event...) to filter before Insert?
Can be achieved only by code modification.
If you are using not big datasets, creating full grid and using deleteRow to delete unnecessary rows after that may be an alternative solution ( it may be too slow for big datasets ) 

Answer posted on Jan 20, 2009 08:33

So, I quit JSON and now try to use the XML, more convenient.

At the start I call loadXML(myprog.php) and for every new added the updateFromXML.

But for the very first time FIREFOX raise an error:    Error type: LoadXML Description: Incorrect XML

the returned string from myprog.php is as:

<?xml version="1.0" encoding="iso-8859-1"?>
<rows total_count=34 pos=0><row id='10000329'><cell> 10:15:46:65 </cell><cell> P </cell><cell> B </cell
><cell> A </cell><cell> 10000329 </cell><cell> 260 </cell><cell> 260 </cell><cell> 0.92 </cell><cell
> D </cell><cell> CB00C </cell><cell> O </cell></row><row...></row>....</rows>
Please, can you see anything wrong with this?
Thanks,
John
Answer posted by dhxSupport on Jan 20, 2009 08:46
The XML looks correct , just check next two things
- there is no any extra whitespace before <?xml declaration ( it is important for FF ) 
- be sure that data which you output are really provided in declared encoding

http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob