I have a NatTable component with the following layers:
I need to show/hide a specific column, when a checkbox selection changes. In order to that, I use the #doCommand() method provided by the NatTable component:
if(selection) {
nattable.doCommand(new ColumnShowCommand(nattable, COLUMN_INDEX));
} else {
nattable.doCommand(new ColumnHideCommand(nattable, COLUMN_INDEX+1));
}
Everything works just fine, excepting the case when ALL the items in the table are selected, and the ColumnHideCommand is executed. On this specific scenario, the whole table content disappears (Screenshot). If there is no selection in the table, or not all the elements are selected, then everything works just fine.
Please let me know if you have any idea what's going on there or if you experienced this kind of issues before. My experience with NatTables is quite limited, so please let me know if you need any additional information. Thank you!
This is a feature of the SelectionLayer
to support multi column hide operations based on the column selection. A ColumnHideCommand
get consumed and instead a MultiColumnHideCommand
is created and executed based on the fully selected columns. The code in charge is located in SelectionLayer#handleColumnHideCommand(ColumnHideCommand)
. The method is protected, so if you don't need that feature because you only support column hide/show programmatically and not via UI performed by a user, you can override the method to simply perform a super.doCommand(command);
without the check for selections.