Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by krzak on Dec 19, 2007 12:55
open dhtmlx forum
setColumnHidden and header is still visible

v1.5

I think there is something wrong with grid initialization/column hiding:

        mygrid = new dhtmlXGridObject('gridbox');
        mygrid.setImagePath("/script/codebase/imgs/");
        mygrid.setSkin("xp");
        mygrid.preventIECaching(true);
        mygrid.setCSVDelimiter("\t");        
        mygrid.enableBlockSelection(true);
        mygrid.setMultiselect(true);
        mygrid.enableAutoWidth(true);
     mygrid.init();
     mygrid.loadXML("data_xml.php");
        mygrid.setColumnHidden(0,true);

....
xml is:

<rows>
<head>
<column width="50" type="ro" align="left" sort="int" id="IDENTIFIER_ID">ID</column>
<column width="150" type="ro" align="left" sort="str" id="IDENTIFIER">Identyfikator</column>
<column width="100" type="ro" align="left" sort="str" id="CODE">Typ</column>
<column width="100" type="ro" align="left" sort="str" id="NAME">Nazwa typu</column>
</head>
<row id="1">
<cell>1</cell>
<cell>FO</cell>
<cell>FOO</cell>
<cell>FOOO</cell>
</row>
</rows>

and as a result, first column itself is hidden, but header for this column is still visible.

this.hdr.rows[1] has no properties
http://localhost/script/codebase/dhtmlxgrid.js
Line 277


I have to mention that if I send XML with <afterInit> tag like this:
<afterInit>
    <call command="setColumnHidden">
<param>0</param>
<param>true</param>
</call>
</afterInit>

then first column is hidden correctly. Moreover (i'm not sure if it's bug) but if I send more than one setColumnHidden with XML then only first one is executed.
Answer posted by Support on Dec 20, 2007 05:38
Correct code is
    mygrid.loadXML("data_xml.php",function(){
            mygrid.setColumnHidden(0,true);
    });

The loading is asyn, so you can't call a command just after loadXML, you need to catch the moment when data will be really loaded.

>>if I send more than one setColumnHidden with XML
The next must work correctly
<afterInit>
    <call command="setColumnHidden"><param>0</param><param>true</param></call>
    <call command="setColumnHidden"><param>1</param><param>true</param></call>
     ... any other call commands here ...
</afterInit>