cscsaba
cscsaba

Reputation: 1289

TreeTable inserting new item (Vaadin)

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

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)

Upvotes: 0

Views: 2491

Answers (2)

cscsaba
cscsaba

Reputation: 1289

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.

Upvotes: 1

Marthin
Marthin

Reputation: 6543

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)

Upvotes: 3

Related Questions