Ok, I have the answers:
1. Why does this happen? The answer is that setHidden(true)
is actually REMOVING the column from the grid. I checked it with the method myListGrid.getFields()
and I have one field LESS after executing the setHidden
method. The field still exists in myDataSource, but it is null
in myListGrid.
2. How to fix this? I fixed it by using the showIf
condition:
myListGrid.addDrawHandler(new DrawHandler() {
public void onDraw(DrawEvent event) {
myListGrid.getField(MyDataSource.COLUMN_ONE).setShowIfCondition(new ListGridFieldIfFunction() {
@Override
public boolean execute(ListGrid grid, ListGridField field, int fieldNum) {
// write the condition needed
// return true/false to respectively show/hide the field
}
});
myListGrid.refreshFields();
}
});
Then, I call myListGrid.refreshFields()
again when needed (upon notification arrived for ex.).
Thank you for your comments and help, however :)