1
votes

I am using Wicket DataTable to display a table. If the data list, which contains the data to be displayed inside the table, is empty then the table gets rendered with all the column headers and a label in the first row saying "No Records Found".

Is there any way to remove this label if the data list is empty and show only the column headers?

1

1 Answers

4
votes

The output is produced by the NoRecordsToolbar. It seems like you don't use a plain DataTable but a DefaultDataTable instead which adds the NoRecordsToolbar in its constructor.

You have (at least) three options:

  • Create a new subclass of DataTable which doesn't add the NoRecordsToolbar.
  • Set the resource key datatable.no-records-found to an empty value.
  • Use the DefaultDataTable but remove the NoRecordsToolbar. Use dataTable.getBottomToolbars().visitChildren(NoRecordsToolbar.class) and remove it. That's not my favorite option because it seems a bit too brittle.