Different behavior between column defs in code and in xml

With both 1.3 and 1.4 Pro, I have a problem when I load tables via XML that wasn’t there when I was doing it in script. When defining the columns in script, everything was as expected. In XML, the grid seems to load and display just fine, but many subsequent operations don’t work or cause errors. Specifically anything that depends on {mygrid}.hdr.rows, such as getColumnCount(), adjustColumnSize(), etc.

The XML looks like (generated by dom4j, tooltip spans removed for clarity…):

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

Summary|Risk Summary|What-If Summary|Historic Risk Summary|Historic VaR Summary|Performance Summary


Gross Exposure

Net Exposure


VaR (Exponential)




ES (Flat)

ES (Exponential)

95% Historic ES


Multi-Strategy Manager






Code is:

this.grid = new dhtmlXGridObject(this.renderTarget);

this.grid.imgURL = “xgrid/imgs/”;

this.grid.enableAlterCss(“even”, “uneven”);

this.grid.enableRowsHover(true, ‘row-over’);



this.grid.loadXML(‘Report/GetReportData?type=’ + renderModel.type);

As said, the thing loads and displays just fine. But soon after:

for (var i = 0; i < len; i++) {



has no effect, and calls to getColumnCount() fail with ‘this.hdr.rows[0] has no properties’ (FF, Safari gives you the ever-useful ‘null value’).

The samples don’t seem to provide any clue to this (which I assume is my problem…). Any thoughts?

Problem can be caused by async. loading of XML. In normal case next instruction after loadXML command will be executed when XML not loaded yet.

Next will not work
    mygrid.loadXML(‘Report/GetReportData?type=’ + renderModel.type);

    var len=mygrid.getColumnCount() //xml not loaded yet, structure is unknown

you can use onXLE event or next correct syntax

    mygrid.loadXML(‘Report/GetReportData?type=’ + renderModel.type,function(){
        //this code will be called only after XML loading
        var len=mygrid.getColumnCount()