Search code examples
javascriptjquerydhtmlx

Cannot call method 'appendChild' of null dhtmlx grid


This is my xml for the grid:

<rows>  
    <row>  
        <cell>101</cell>  
        <cell>some name</cell>  
        <cell>917</cell>
    </row>
</rows>

I get it as data.data via Ajax.

In the success of the Ajax call I have this:

myGrid.attachHeader(data.filters);
if (data.widths != undefined) myGrid.setInitWidths(data.widths);
myGrid.setColTypes(data.types);
myGrid.init();
myGrid.loadXMLString(data.data, function () { });

And it crashes on this line:

myGrid.loadXMLString(data.data, function () { });

I get the error "Cannot call method 'appendChild' of null".

But everything have good values. myGrid is ok, data.data has ok values. What seems to be the problem?


Solution

  • appendChild method is not directly related to the xml parsing, and may be caused by some grid misconfiguration, or attaching grid to non-existing html container.

    When grid process loadXMLString it will try to render the column structure for first time, which in case of incorrect configuration can lead to the above error.