0

I'm trying to get the number of visible columns (ListGridField) in a ListGrid.

Is there an easy solution for that?

Kimi
  • 6,239
  • 5
  • 32
  • 49

2 Answers2

3

Here's the solution using ListGrid.fieldIsVisible(String fieldName) method:

private int getNumVisibleColumns(ListGrid grid) {
    int count = 0;
    for (ListGridField field : grid.getFields()) {
        if (grid.fieldIsVisible(field.getName())) {
            count++;
        }
    }
    return count;
}
Kimi
  • 6,239
  • 5
  • 32
  • 49
  • When you say the field is hidden. Do you mean ListGridField.hidden is true ? I am trying to do the same thing. But it is not working. – Kanwaljeet Singh Oct 30 '14 at 08:30
-1

you can loop through the columns in the ListGrid and call ListGridField.getHidden() to count which ones are visible or not.

Holograham
  • 1,348
  • 1
  • 13
  • 34
  • 1
    Sorry, but there's no such method as `getHidden()` in the _ListGridField_ class.[link](http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/grid/ListGridField.html) However, I came up with a solution. – Kimi May 20 '11 at 07:30