Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by adam f on Oct 26, 2009 11:15
open dhtmlx forum
getColumnId returnd undefined

currently I'm using the grid control, loading all row and column definitions from a php file returning an xml string.

if I call getColumnId on a valid column index I get a column id I expect.

however when I call clearAll and loadXML to refresh the data all subsiquent calls to getColumnId return 'undefined'.

to clarify i make the calls in this order

loadXML
getColumnId, this first one works.
clearAll
loadXML
getColumnId, this one fails.
Answer posted by Stanislav (support) on Oct 26, 2009 13:18
Are you using 
    grid.clearAll()
or
    grid.clearAll(true)
?

In second case structure of grid deleted as well, info about column's ID is deleted with the grid's structure.
Answer posted by adam f on Oct 26, 2009 13:27
I'll need to be more explicit I guess

grid.loadXML(data.php);
grid.getColumnId(1); //is good
grid.clearAll();
grid.loadXML(data.php);
grid.getColumnId(1); // fails

data.php always returns ' <rows><head><column type="ro" width="150">Employee</column><column type="ro" width="150" id="2009-10-21">21 OCT 2009</column><column type="ro" width="150" id="2009-10-23">23 OCT 2009</column></head><row id=" 11274" ><cell>11274</cell><cell/><cell><![CDATA[<a onclick='loadWindow(" 11274","2009-10-23")' >8:00 ADP/ 8:00 Timecard </a>]]></cell></row><row id=" 11275" ><cell>11275</cell><cell><![CDATA[<a onclick='loadWindow(" 11275","2009-10-21")' >5:45 ADP/ 5:15 Timecard </a>]]></cell><cell/></row></rows>'

note the full header block.
Answer posted by dhxSupport on Oct 27, 2009 01:37
You always returning xml with grid structure. So to reload grid with such xml you should clear grid structure:

grid.loadXML(data.php);
grid.getColumnId(1); //is good
grid.clearAll(true);

Also you should wait till grid is initialized and loaded before calling grid.getColumnId(1):

grid.loadXML(data.php,function(){
grid.getColumnId(1); 
});

Answer posted on Oct 27, 2009 05:52
Never mind I found a work around.