public AddressbookTree() { super(); SectionStackSection section = new SectionStackSection(); section.setCanCollapse(false); section.setExpanded(true); section.setResizeable(true); TreeGrid tree = new TreeGrid(); tree.setWidth100(); tree.setHeight100(); tree.setAnimateFolderTime(100); tree.setAnimateFolders(true); tree.setAnimateFolderSpeed(1000); tree.setShowSortArrow(SortArrow.CORNER); tree.setShowAllRecords(true); tree.setLoadDataOnDemand(false); tree.setCanSort(false); tree.setCellHeight(17); tree.setShowHeader(false); TreeGridField field = new TreeGridField(); field.setCanFilter(true); field.setName("name"); field.setTitle("<b>SmartGWT Showcase</b>"); tree.setFields(field); Tree treeData = new Tree(); treeData.setModelType(TreeModelType.PARENT); treeData.setNameProperty("name"); treeData.setOpenProperty("isOpen"); treeData.setIdField("nodeID"); treeData.setParentIdField("parentNodeID"); treeData.setRootValue("root"); treeData.setData(DemoData.getAddressBookTreeData()); tree.setData(treeData); section.setItems(tree); setSections(section); }
public Canvas getViewPanel() { EmployeeXmlDS employeesDS = EmployeeXmlDS.getInstance(); TreeGrid treeGrid = new TreeGrid(); treeGrid.setCanEdit(true); treeGrid.setLoadDataOnDemand(false); treeGrid.setWidth(500); treeGrid.setHeight(400); treeGrid.setDataSource(employeesDS); treeGrid.setNodeIcon("icons/16/person.png"); treeGrid.setFolderIcon("icons/16/person.png"); treeGrid.setShowOpenIcons(false); treeGrid.setShowDropIcons(false); treeGrid.setClosedIconSuffix(""); treeGrid.setAutoFetchData(true); TreeGridField nameField = new TreeGridField("Name"); TreeGridField jobField = new TreeGridField("Job"); TreeGridField salaryField = new TreeGridField("Salary"); salaryField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value != null) { NumberFormat nf = NumberFormat.getFormat("#,##0"); try { return "$" + nf.format(((Number) value).longValue()); } catch (Exception e) { return value.toString(); } } else { return null; } } }); treeGrid.setFields(nameField, jobField, salaryField); return treeGrid; }
public Canvas getViewPanel() { DataSource employeeDS = EmployeeXmlDS.getInstance(); final TreeGrid treeGrid = new TreeGrid(); treeGrid.setLoadDataOnDemand(false); treeGrid.setWidth(500); treeGrid.setHeight(400); treeGrid.setDataSource(employeeDS); treeGrid.setNodeIcon("icons/16/person.png"); treeGrid.setFolderIcon("icons/16/person.png"); treeGrid.setShowOpenIcons(false); treeGrid.setShowDropIcons(false); treeGrid.setClosedIconSuffix(""); treeGrid.setAutoFetchData(true); TreeGridField field = new TreeGridField(); field.setName("Name"); field.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return record.getAttribute("Job") + ": " + value; } }); treeGrid.setFields(field); treeGrid.addDataArrivedHandler( new DataArrivedHandler() { public void onDataArrived(DataArrivedEvent event) { treeGrid.getData().openAll(); } }); return treeGrid; }