Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by David on Aug 08, 2008 09:14
open dhtmlx forum
Override //rows/head

The xmlB format allows you to override the default xml path to get data by using the following code...

mygrid.xml.top=.... & mygrid.xml.row=....

Is there a similiiar option to override the header meta data ? //rows/head/ is the default path to get header information.
Answer posted by Support on Aug 08, 2008 09:33
The header structure is hardcoded and can't be reset through options. 
Can be changed only by code modification
 dhtmlxgrid.js , _parseHead method

 _parseHead:function(xmlDoc){
  var hheadCol = this.xmlLoader.doXPath("//rows/head", xmlDoc);
 
  if (hheadCol.length){
  var headCol = this.xmlLoader.doXPath("//rows/head/column", hheadCol[0]);
  var asettings = this.xmlLoader.doXPath("//rows/head/settings", hheadCol[0]);

Answer posted by David on Aug 08, 2008 13:26
I put the suggested fix above but there is another error elsewhere.  I think it's in dhtmlxgrid_data.js, somewhere around 'r.childNodes[j]._attrs=this._xml_attrs(cellVal);'

Please see attached and run headers-xmlB.html.  This scenario uses xmlB format for the data and custom head/column tags.

NOTE: changes were made...

dhtmlxgrid_data.js
 - dhtmlXGridObject.prototype._process_xmlB=function(xml)
        // var id=rows[i].getAttribute("id");
        var id=xml.doXPath("./id",rows[i])[0].firstChild.data;    
       
dhtmlxgrid.js
 - _parseHead:function(xmlDoc){
     var xmlHead = "rows/head";
     if (this.xml.head != undefined) xmlHead = this.xml.head;
    
     var xmlHeadColumn = xmlHead+ "/column";
     if (this.xml.column != undefined) xmlHeadColumn = this.xml.column;
    
     var xmlHeadSettings = xmlHead + "/settings";    
     if (this.xml.settings != undefined) xmlHeadSettings = this.xml.settings;
 
     var hheadCol = this.xmlLoader.doXPath("//" +xmlHead, xmlDoc);
     if (hheadCol.length){
         var headCol = this.xmlLoader.doXPath("//" +xmlHeadColumn, hheadCol[0]);
         var asettings = this.xmlLoader.doXPath("//" +xmlHeadSettings, hheadCol[0]);

Also, are any changes required in ....dhtmlxgrid.js(349) ?  There are references to <head> and <column...
Answer posted by Support on Aug 11, 2008 02:00
During loading XML configuration, grid reset configuration settings, including column IDs, so on moment of data loading info about column IDs reset and grid just can't map data tags to columns. 
To resolve issue, you can put columns IDs in head section of XML

<headzzz>
  <columnzzz id="id" type="ro" width="50" align="right" sort="int">ID</columnzzz>
  <columnzzz id="theName" type="ro" width="550" align="left" sort="str">Name</columnzzz>
  <columnzzz id="theStatez" type="ro" width="550" align="left" sort="str">State</columnzzz>
 </headzzz>


Also, when reloading grid structure it better to use 
  function withHeader() {
       mygrid.clearAll(true);

When command called without parameter it clears just data, not structure of grid. 


Answer posted by David on Aug 18, 2008 17:24

Thx.  This works.

In addition, I'm trying to get splitAt, paginate, filtering, eventHandling and serialization to work.   Also, my project requires that all (or most) configurations be loaded in the <head> tags... WITH the 2 criteria defined below

So far, I tried splitAt() and I'm running into issues. Please see attached.

Can you modify the library to include the following...

(1) in addition to different xml formats for top/row/cell, include custom xml formats for top/head/beforeInit and top/head/afterInit, etc. (i've made several changes in the attached files, but it looks like there are more because splitAt is not working)

(2) using <id> element instead of "id" attribute. There are several places in the code that is referencing "id" attribute.

David

Answer posted by Support on Aug 19, 2008 02:44
Problem with split is not related to used datasource.
Split must be executed after configuration defined, just replace beforeInit with afterInit in your XML and all will work correctly.

>>There are several places in the code that is referencing "id" attribute.
Except of process_xml method, which redefined for xmlB format, the only reference for "id" attribute is in updateFromXML method , which , currently, can be used only with default XML format.

>>(1) in addition to different xml formats for top/row/cell, include custom xml formats for top/head/beforeInit and top/head/afterInit
Most probably, in next version, we will move all used XPaths to separate object, so they can be configured without code modificaiton.
Answer posted by David on Aug 19, 2008 12:13
Thx for the response... but I'm still having trouble getting it to work putting the splitAt function in afterInit.  I tried various things.  Can you pls download the attached code and identify the issue ?
Answer posted by Support on Aug 21, 2008 02:17

In attached sample - all samples with split actually work. The width of  row is lesser than width of grid - so no scrollbars necessary and split not visible - just resize any column beyond the grid borders and visible scroll will appear.

Problems with clearAll(true) and double calls - the grid in split mode can't change its configuration, which mean, after splitAt executed, you can executed the same command with different value or reload grid configuration from XML , only data can be reloaded. If you need to change config - the only solution - full grid reconstruction. 

grid.destructor();
grid = new dh...
grid.loadXML("config.xml")

Answer posted by David on Aug 20, 2008 14:54
thx, you are correct.  the splitAt works.  my mistake.

"Most probably, in next version, we will move all used XPaths to separate object, so they can be configured without code modificaiton."

do you have an estimated time of delivery for these changes ?  i think your library is very good, however, I need it to work w/ my webservice response xml.  In the next version, can you pls provide working examples of all features using the "xmlB" format.


Answer posted by Support on Aug 21, 2008 02:18
>>do you have an estimated time of delivery for these changes 
It is too late to include such modification in next version ( release planed on the end of August ) - so they will be included in version next to oncoming one.