Clear whole Table

Hello forums!

I could need some help with a problem!

I’m creating a table with

 Table tab = new Table();

After that I’m filling the table with some Headers and a single line of data

  tab.addContainerProperty("Filter", String.class, null);
  tab.addContainerProperty(elm, String.class, null); (this will be run 2x with different Strings in elm)
  
  tab.addItem(new Object[]{"Some Filter", "x"},1);

Now I want to clear the whole table after I press a certain button/launching a certain function. How can I do that.

Please not that i also want to delete the ContainerProerties so the whole table would be emtpy again.

Thanks for the help!
Patrick

Hi,

what if you just create a new Table? That sounds like the easiest way to do it.

-Olli

Hi Olli,

Thanks for the tip, but I solved it myself!

Here’s how:

    private void clearTable(Table tab, boolean clearHead){
        tab.removeAllItems();
        if(clearHead){
            for(Object col: tab.getContainerPropertyIds().toArray())  {
                tab.removeContainerProperty(col);
            }
        }
    }