Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by bchien on Nov 07, 2007 14:21
open dhtmlx forum
column sort issue for treegrid

I am using the dhtmlXTreeGrid 1.4 professional version and has an issue for the column sorting. here are my code snippet:
    mygrid = new dhtmlXGridObject('entityJurBox');

    mygrid.selMultiRows = true;
    mygrid.imgURL = "/ams/resources/img/dhtmlxTreeGrid/";
mygrid.setHeader("Jurisdiction,Filing,Nexus,Nexus Flow,PL 86-272,Rule,Apportionment,Rate"); // header names
mygrid.setInitWidths("150,100,100,100,100,100,100,100"); // initial header widths
mygrid.setColAlign("left,left,left,left,left,left,left,left");
mygrid.setColTypes("tree,ed,ch,ch,ch,coro,edn,edn");
mygrid.setColSorting("str,str,str,str,str,str,str,str");
mygrid.setNumberFormat("0.000000%",6);
mygrid.setNumberFormat("0.000000%",7);
mygrid.enableColumnAutoSize(true);

mygrid.attachEvent("onEditCell",function(stage, row, col){
if (col==2 || col==4 || col==5)
return true;
return false;
});

mygrid.enableAlterCss("banded","");
mygrid.init();
//mygrid.splitAt(1);
mygrid.loadXML("/ams/entityJurisdictionServlet?entityId=${entity.id}");

As you may be aware, I have a servlet which generates the XML data for tree grid to render. The treegrid displays data as expected. However, when I click the column header 9any header) to sort, I got the javascript error said "Line: 2130 Error: '_childIndexes' is null or not an object". When I set the alert in the line 2130, dhtmlXGrid.js, I found that row_id=undefined, which cause the above error.

If I create an XML file contains the same data, the column sort is working. So what did I miss?

Here are the data I try to render.
<?xml version="1.0" encoding="UTF-8"?>
<rows>
    <row id="NY">
        <cell image="folder.gif">New York</cell>
        <cell image="red.gif">Unitary</cell>
        <cell>true</cell>
        <cell></cell>
        <cell>false</cell>
        <cell></cell>
<cell></cell>
        <cell>7.5</cell>
        <row id="NY-NYC">
            <cell image="leaf.gif">New York City</cell>
            <cell image="red.gif">Unitary</cell>
            <cell>true</cell>
<cell></cell>
            <cell>false</cell>
<cell></cell>
<cell></cell>
            <cell>8.85</cell>
        </row>
    </row>

    <row id="GA">
        <cell image="leaf.gif">Georgia</cell>
        <cell image="red.gif">Unitary</cell>
        <cell>true</cell>
<cell></cell>
        <cell>false</cell>
<cell></cell>
<cell></cell>
        <cell>6.0</cell>
    </row>
</rows>
Answer posted on Nov 08, 2007 05:22
The code which you are provided works fine with static XML, so most probably error somewhere in your servlet which generates XML
Similar problem can occur if you data XML contains empty or not-unique IDs of rows ( in such case grid may render correctly, but any row related action will cause such error )

Please be sure that each row in generated XML contains unique ID , to check data fetched from your servlet you can use attached file instead of default dhtmlxcommon.js♠
Attachments (1)