employeeTree.setParentIdField("ReportsTo");
employeeTree.setOpenProperty("isOpen");
employeeTree.setData(employeeData);
final TreeGrid employeeTreeGrid = new TreeGrid();
employeeTreeGrid.setWidth(200);
employeeTreeGrid.setHeight(240);
employeeTreeGrid.setNodeIcon("icons/16/person.png");
employeeTreeGrid.setFolderIcon("icons/16/person.png");
employeeTreeGrid.setShowOpenIcons(false);
employeeTreeGrid.setShowDropIcons(false);
employeeTreeGrid.setClosedIconSuffix("");
employeeTreeGrid.setData(employeeTree);
employeeTreeGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
employeeTreeGrid.setShowSelectedStyle(false);
employeeTreeGrid.setShowPartialSelection(true);
employeeTreeGrid.setCascadeSelection(true);
employeeTreeGrid.addDrawHandler(new DrawHandler() {
public void onDraw(DrawEvent event) {
employeeTreeGrid.getTree().openAll();
}
});
DynamicForm df = new DynamicForm();
final CheckboxItem partialSelection = new CheckboxItem("partialSelect", "Allow Partial Selection");
partialSelection.setDefaultValue(true);
partialSelection.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
boolean selected = partialSelection.getValueAsBoolean();
employeeTreeGrid.setShowPartialSelection(!selected);
employeeTreeGrid.redraw();
}
});
df.setFields(partialSelection);