Esempio n. 1
0
  public Canvas getViewPanel() {
    ColumnTree columnTree = new ColumnTree();
    columnTree.setWidth100();
    columnTree.setHeight(205);
    columnTree.setDataSource(EmployeeXmlDS.getInstance());
    columnTree.setAutoFetchData(true);
    columnTree.setNodeIcon("icons/16/person.png");
    columnTree.setFolderIcon("icons/16/person.png");
    columnTree.setShowOpenIcons(false);
    columnTree.setShowDropIcons(false);
    columnTree.setClosedIconSuffix("");

    columnTree.setShowHeaders(true);
    columnTree.setShowNodeCount(true);
    columnTree.setLoadDataOnDemand(false);
    return columnTree;
  }
  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;
  }