简体   繁体   中英

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?

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.

I would assume there is a problem internal to loadXMLString preventing it from parsing the xml you are passing in. Given that we cannot see the code that dhtmlx is using I'm not quite sure what it could be.

  • Problems parsing whitespace between nodes?
  • Unexpected text literals between nodes (like improperly escaped \\r or \\n)?
  • Are you able to successfully execute $.parseXML(data.data) ?

I used below code to fix this problem,

myGrid.setHeader(...);
myGrid.setColumnIds(...);
myGrid.Init();

then I called myGrid.loadXmlString

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM