public Canvas getViewPanel() { Tree employeeTree = new Tree(); employeeTree.setModelType(TreeModelType.PARENT); employeeTree.setRootValue(1); employeeTree.setNameProperty("Name"); employeeTree.setIdField("EmployeeId"); employeeTree.setParentIdField("ReportsTo"); employeeTree.setOpenProperty("isOpen"); employeeTree.setData(employeeData); TreeGridField formattedField = new TreeGridField("Name"); formattedField.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return record.getAttributeAsString("Job") + ": " + value; } }); TreeGrid employeeTreeGrid = new TreeGrid(); employeeTreeGrid.setWidth(500); employeeTreeGrid.setHeight(400); employeeTreeGrid.setNodeIcon("icons/16/person.png"); employeeTreeGrid.setFolderIcon("icons/16/person.png"); employeeTreeGrid.setCanReorderRecords(true); employeeTreeGrid.setCanAcceptDroppedRecords(true); employeeTreeGrid.setShowOpenIcons(false); employeeTreeGrid.setDropIconSuffix("into"); employeeTreeGrid.setClosedIconSuffix(""); employeeTreeGrid.setData(employeeTree); employeeTreeGrid.setFields(formattedField); return employeeTreeGrid; }
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() { Tree employeeTree = new Tree(); employeeTree.setModelType(TreeModelType.PARENT); employeeTree.setIdField("EmployeeId"); employeeTree.setParentIdField("ReportsTo"); employeeTree.setNameProperty("Name"); employeeTree.setRootValue(1); employeeTree.setData(employeeData); TreeGrid employeeTreeGrid = new TreeGrid(); employeeTreeGrid.setWidth(500); employeeTreeGrid.setHeight(400); employeeTreeGrid.setNodeIcon("icons/16/person.png"); employeeTreeGrid.setFolderIcon("icons/16/person.png"); employeeTreeGrid.setShowOpenIcons(false); employeeTreeGrid.setShowDropIcons(false); employeeTreeGrid.setClosedIconSuffix(""); employeeTreeGrid.setFields(new TreeGridField("Name")); employeeTreeGrid.setData(employeeTree); employeeTreeGrid.getData().openAll(); return employeeTreeGrid; }
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; }