2012-04-03 49 views
2

嗨下面從Vaadin的鏈接,你可以看到如何設置tabletree上的複選框,但我不希望所有的節點有一個複選框,但只有一個字符串,只有一些。這是可能的嗎?vaadin如何選擇性地把複選框放在treetable

vaadin treetable example url

+0

如果傳遞null而不是複選框對象 – fmucar 2012-04-03 14:14:56

+0

@fmucar但我希望有一個標題出現,會發生什麼? – Spring 2012-04-03 15:00:21

+2

您可以嘗試在容器中爲該列創建類Component,並添加CheckBox或Label或其他組件,無論您想要哪個 – fmucar 2012-04-03 15:38:38

回答

3

fmucar告訴答案,你可以做到這一點,通過在treetable中添加生成列這樣

treeTable.addGeneratedColumn("generated", new ColumnGenerator() { 

@Override 
public Component generateCell(Table source, final Object itemId, Object columnId){ 

    // Get the object associated with the row 
    Object Objet = source.getItem(itemId); 

    //Missing casting instruction 

    if(your condition to check to render a CheckBox()){ 
     return new CheckBox(); 
    } 

    return new Label("your text"); 
} 

});

問候