Grid rows are loaded as blank with custom XML format

Hi
I have loaded custom XML into a grid, the loading of rows is seen properly but the data is blank in all the rows. Totally 1153 rows are loaded with blank data. The code that I have used is as follows in italics and bold font:

[b][i]

[/i][/b]

The image of the loading is attached. Kindly help out matter urgent as we have a delivery milestone pending on Tuesday, November 3, 2015.

Thanks in advance
Regards
Manish.


Hi DHX Team,
Can anyone please respond to this query of mine? I’m testing some reusable artifacts based on this dynamic grid loading. Kindly respond faster.

Thanks much in response.

Regards
Manish.

I apologize for the delay with your request.
Could you please, share with the example of your custom using xml.

Please find attached the xml file in zip format.
GetUsers.zip (19.4 KB)

Hi Sematik,
I have also tried loading the grid with another xml file, and the same is attached for your perusal.
Hope this helps out in speeding up the resolution as this is a small file. The code used is given below for your review.

Thanks in advance.
Regards
Manish.

GetMyProfile.zip (411 Bytes)

IN case of using the individual tag name for each column (column ids) the only solution is to create a custom xml type.
Here you can find a tutorial with a similar example:
docs.dhtmlx.com/grid__data_forma … dataformat

NOTE about the tutorial:
since the dhtmlxGrid 4.0 you need to use:
dhx4.ajax.xpath
instead of:
xml.doXPath

Hi Sematik,
Even that doesn’t work. This is the error I get in the console.

Uncaught TypeError: Cannot set property ‘_process_custom_xml’ of undefineddoOnLoad @ newgrid_load.html:11onload @ newgrid_load.html:49

Do tell me what is wrong. My new code as per your instructions is given below. The XML file remains the same.

[b][i]

[/i][/b]

Also tell me why I can’t use:

myGrid.xml.top=“modules”;
myGrid.xml.row="./clientse164";
myGrid.init();
myGrid.load("./GetUsers.xml",“xml”);

For custom XML loading this is the most convenient code. Do tell me what should I do in order to use the above code. This is got really frustrating, please expedite the same.

Thanking you
With regards
Manish.

After correcting some syntax errors, I still get this message as below:

Uncaught TypeError: Cannot read property ‘nodeName’ of undefinedwindow.dhx4.ajax.xpath @ dhtmlx.js:9myGrid._process_custom_xml @ newgrid_load.html:13xmlLoader @ dhtmlx.js:9(anonymous function) @ dhtmlx.js:9

Also, my corrected code is as below:

[b]

[/b]

The following code works well for me:

[code]myGrid._process_custom_xml=function(xml){
this._parsing=true;
var top=dhx4.ajax.xmltop(“modules”, xml);
var rows = dhx4.ajax.xpath("./clientse164",top); //gets all row elements from XML
for (var i = 0; i < rows.length; i++){
var id = this.getUID(); //XML has no native ids,so custom ids are generated
this.rowsBuffer[i]={ //stores references to each row element
idd: id,
data: rows[i],
_parser: this._process_custom_xml_row, //cell parser method
_locator: this._get_custom_xml_data //data locator method
};

    this.rowsAr[id]=rows[i];             //stores id reference
}
this.render_dataset();            //forces update of grid's view after data loading
this._parsing=false;

};

myGrid._process_custom_xml_row=function(r, xml){
var client = dhx4.ajax.xpath("./id_client", xml)[0];
var login = dhx4.ajax.xpath("./login", xml)[0];
var password = dhx4.ajax.xpath("./password", xml)[0];
var type = dhx4.ajax.xpath("./type", xml)[0];
var tariff = dhx4.ajax.xpath("./id_tariff", xml)[0];
var state = dhx4.ajax.xpath("./account_state", xml)[0]; 
var reseller = dhx4.ajax.xpath("./id_reseller", xml)[0];
var type2 = dhx4.ajax.xpath("./type2", xml)[0];
var currency = dhx4.ajax.xpath("./id_currency", xml)[0];
var proxy = dhx4.ajax.xpath("./media_proxy", xml)[0]; 
var name = dhx4.ajax.xpath("./full_name", xml)[0];
var email = dhx4.ajax.xpath("./email", xml)[0];
var status = dhx4.ajax.xpath("./status", xml)[0];
var first = dhx4.ajax.xpath("./first_use", xml)[0];
var last = dhx4.ajax.xpath("./last_use", xml)[0];
var strAr = [  
    (client?client.firstChild.data:""),
    (login?login.firstChild.data:""),
    (password?password.firstChild.data:""),
    (type?type.firstChild.data:""),
    (tariff?tariff.firstChild.data:""),
    (state?state.firstChild.data:""),
    (reseller?reseller.firstChild.data:""),
    (type2?type2.firstChild.data:""),
    (currency?currency.firstChild.data:""),
    (proxy?proxy.firstChild.data:""),
    (name?name.firstChild.data:""),
    (email?email.firstChild.data:""),
    (status?status.firstChild.data:""),
    (first?first.firstChild.data:""),
    (last?last.firstChild.data:"")
];
//sets just a plain array as no custom attributes are needed
r._attrs={};
for (j=0; j < r.childNodes.length; j++) r.childNodes[j]._attrs={};

//finishes data loading 
this._fillRow(r, strAr);
return r;

}[/code]

Hi Sematik,
The code doesn’t work for me. Please see the error message I get:

Uncaught TypeError: Cannot read property ‘appendChild’ of null @ dhtmlx.js:9
dhtmlXGridObject._insertRowAt @ dhtmlx.js:9
dhtmlXGridObject.render_dataset @ dhtmlx.js:9
myGrid._process_custom_xml @ newgrid_load.html:26
xmlLoader @ dhtmlx.js:9
(anonymous function) @ dhtmlx.js:9

The code I’ve used – the same one you sent-- in the HTML file is as below:
[b]

[/b]

the header for your grid is missing:
myGrid.setHeader(…);
column ids are not defined:
myGrid.setColumnIds(…);

Hi Sematik,
Despite adding headers and column IDs for the grid, I still get the same error, however with different numbers. Please find them below. Do let me know if this facility actually works as I get error message that there’s a problem in the dhtmlx.js on line number 9.

In case this doesn’t work out, can you show me a way to load XML cleaned from the input xml file ( I have done that) into the grid, with default column IDs as headers. I’ll find a way out after that. A tad disappointed as this facility is not working despite me trying. Find my code below the error messages:
==============================Error Messages==========================================
Uncaught TypeError: Cannot read property ‘appendChild’ of null @ dhtmlx.js:9
dhtmlXGridObject._insertRowAt @ dhtmlx.js:9
dhtmlXGridObject.render_dataset @ dhtmlx.js:9
myGrid._process_custom_xml @ newgrid_load.html:32
xmlLoader @ dhtmlx.js:9
(anonymous function) @ dhtmlx.js:9

=================================My Code=============================================
[b]

[/b] =====================================================================================

mygrid.init() method is missing.

could you refer to your original init of the grid as an example?

Thanks a lot, Sematik. It works. Thanks for your support and patience.