Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by andreea on May 19, 2008 02:32
open dhtmlx forum
How could I make the entire column that doesn't contain any values in its cells not visible?


How could I make the entire column that doesn't contain any values in its cells not visible?

This is the header : ,Image,Reference ID,Client,Bridges (for road bridges alos tick \'road\', heavy rail bridges \'heavy rail\', etc ….),#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,Segmental bridges,#cspan,Cable stayed bridges,#cspan,#cspan,Environment,#cspan,Front-end servicesE,#cspan,#cspan,ecological analysis and this is the XML contain :
[ ... data skipped ...]

I need the columns length, Height,...(and all the empty columns) to not appear

Answer posted by Support on May 19, 2008 07:38

You can use

grid.setColumnHidden(index,true)
or
grid.setColumnsVisibility(list)

commands to hide show any column or list of columns
This command must be executed after grid.init

Please beware, that in case of colspans in header, you need to hide|show all columns included in colspan at once

Answer posted by MasterEmit on Jul 03, 2008 04:32
If you want to hide it automatically, if the content is empty, do the following steps:

- save the label of the column inside a variable (getColumnLabel)
- set label to an empty string
- save the current width of the column inside a variable (getColWidth)
- perform adjustColumnSize
- check, if width is smaller than 3 pixel, if yes, then there is no content inside
- now you can set label (setColumnLabel) and width (setColWidth) back and depending on your decision hide the column (setColumnHidden)
Answer posted by Stanislav on Jul 07, 2008 08:27
>>if the content is empty, do the following steps
The next code may be a bit more simple way to detect is column empty or not

var empty=true;
mygrid.forEachRow(function(id){
    if (mygrid.cells(id,index).getValue()) empty=false;
});