Question

I'm developing an GIS app which can have map layers turned on by default. When layer is on, the checkbox of the Checkbox TreeGrid should be checked.

I've tried to add "checked" field to my tree's BaseModel:

public boolean getChecked() {
    return (Boolean) get("checked");
}

public void setChecked(boolean b) {
    set ("checked", true);
}

But it hasn't give any results. How can I set checkboxes of CheckboxTreeGrid initially checked?

Was it helpful?

Solution

I've figured it out.

The following code should be fired in in Events.ViewReady event of Checkbox TreeGrid, because nodes in tree root won't be rendered before. Then expandAll() is used to render all tree children. Variable checkedItems contains a List items which you want to be checked on the tree.

be.getTreeGrid().expandAll();
be.getTreeGrid().setCheckedSelection(checkedItems);
be.getTreeGrid().collapseAll();  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top