TreeTable inserting new item (Vaadin)

2.5k Views Asked by At

I have a TreeTable and I could initialize it with elements, and they are shown. But much later I could not insert new elements.

  • every treetable.addItem(...) gives null later
  • the methods in the initialization can not insert new elements either later.
  • every new item has an unique itemid
  • i did not get any error message

How can I find out what is the real problem ?

I'm sure I added the proper types in the proper order.

Thanks in advance.

(insertion of code snippet would be boring long because we have 10 column)

2

There are 2 best solutions below

0
On

I noticed what was the "problem". After using setVisibleColumns I could not add new item. as I commented it the new item could go into treetable. Test it yourself (Vaadin 6.7.3-4)

    TreeTable tt = new TreeTable();
    mainWindow.addComponent(tt);

    tt.addContainerProperty("description", String.class, "");
    tt.addContainerProperty("keyword", String.class, "");
    tt.addContainerProperty("priority", String.class, "");

    tt.addItem(new Object[]{"0","k 0","p 0"},0);
    tt.addItem(new Object[]{"1","k 1","p 1"},1);
    tt.addItem(new Object[]{"2","k 2","p 2"},2);
    //tt.addItem(new Object[]{"3","k 3","p 3"},3);  //works well    

    tt.setVisibleColumns(new Object[] {"description","keyword"});       

    tt.addItem(new Object[]{"3","k 3","p 3"},3);    //doesn't work because of setVisibleColumns ....        

Strange ...

Cs.

1
On

It's very hard to know what is wrong when you don't give any code but it could be that your table doesn't allow new objects. Use this method to change it

myTreeTable.setNewItemsAllowed(true)