Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Mike on Feb 03, 2009 08:19
open dhtmlx forum
reloading grid from xml

I am trying to load a grid using xml afte the grid has been initially created. I currently have the free version and therefore, cannot use the reloadXML method. Is there a way to load the grid using xml? I have other grids where I have to parse the xml and create a JavaScript array and call addRow, but I do not want to do that if I don't have to.

Answer posted by Support on Feb 03, 2009 08:29
Just use 

grid.clearAll() //delete old data
grid.loadXML(url) //load new data

>>and create a JavaScript array and call addRow
beware that loading data in such way is slower than loading directly from datasource
also grid can use 
   grid.parse(data,"jsarray") 
to load data directly from javascript array
Answer posted by Mike on Feb 03, 2009 10:14

Using loadXML(xml) produced an error message (see below).

 

Using parse(xml,'xml') did not produce the error message.

 

Error Type: LoadXML

Description: Incorrect XML

XML is:

<?xml version="1.0" encoding="UTF-8"?>

<rows>

<row id="1">

<cell>1</cell>

<cell>121</cell>

<cell>Scheduled Search Test</cell>

<cell>12</cell>

<cell>1</cell>

<cell>100</cell>

<cell>01/30/2009 08:57</cell>

</row>

<row id="2">

<cell>2</cell>

<cell>121</cell>

<cell>Scheduled Search Test</cell>

<cell>12</cell>

<cell>2</cell>

<cell>100</cell>

<cell>01/30/2009 09:57</cell>

</row>

<row id="3">

<cell>3</cell>

<cell>121</cell>

<cell>Scheduled Search Test</cell>

<cell>12</cell>

<cell>3</cell>

<cell>100</cell>

<cell>01/30/2009 11:15</cell>

</row>

<row id="4">

<cell>4</cell>

<cell>121</cell>

<cell>Scheduled Search Test</cell>

<cell>12</cell>

<cell>4</cell>

<cell>100</cell>

<cell>02/02/2009 07:47</cell>

</row>

</rows>

Answer posted by Support on Feb 04, 2009 02:48
If xml generated by some kind of script , please be sure that
 - xml sent to client side with correct content type ( text/xml )
 - there is no unnecessary whitespace before <?xml declaration
http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob