Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dynamically changing ListGrid fields visibility causes ClassCastException

    Hi,

    In a ListGrid, I'm trying to change dynamically the list of visible fields (columns).

    The code that handles a visibility change looks like this:

    Code:
    ListGridField[] fields = grid.getDefaultFields();
    for (ListGridField field : fields) {
        String name = field.getName();
        field.setHidden(!visibleFields.contains(name));
    }
    grid.setFields(fields); // this throws several ClassCastExceptions, but why!?
    Although several ClassCastExceptions are thrown, the grid is able to hide and display the fields as instructed, but I'm puzzled on why the exceptions occurred.

    PS - I have tried the alternative grid.showField(name) and grid.hideField(name) but the performance of this solution is prohibitive. Changing all fields visibility at once takes a lot less time. The only way I have found to change all fields visibility at once is using grid.setFields(fields).
Working...
X