/* * Isomorphic SmartGWT web presentation layer * Copyright 2000 and beyond Isomorphic Software, Inc. * * OWNERSHIP NOTICE * Isomorphic Software owns and reserves all rights not expressly granted in this source code, * including all intellectual property rights to the structure, sequence, and format of this code * and to all designs, interfaces, algorithms, schema, protocols, and inventions expressed herein. * * If you have any questions, please email
. * * This entire comment must accompany any portion of Isomorphic Software source code that is * copied or moved from this file. */ package com.smartgwt.sample.showcase.client.dataintegration.java.tree; import com.google.gwt.core.client.GWT; import com.smartgwt.client.data.*; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.tree.TreeGrid; import com.smartgwt.client.widgets.tree.Tree; import com.smartgwt.client.widgets.tree.TreeNode; import com.smartgwt.sample.showcase.client.PanelFactory; import com.smartgwt.sample.showcase.client.ShowcasePanel; public class TreeBindingServletSample implements EntryPoint { public void onModuleLoad() { DataSource dataSource = DataSource.get("supplyCategoryDS"); if (dataSource == null) { dataSource = new DataSource(); dataSource.setDataURL(GWT.getModuleBaseURL() +"/supplyCategoryOperations.do"); dataSource.setID("supplyCategoryDS"); } DataSourceTextField categoryName = new DataSourceTextField("categoryName", "Item", 128); categoryName.setPrimaryKey(true); DataSourceTextField parentID = new DataSourceTextField("parentID"); parentID.setHidden(true); parentID.setForeignKey("supplyCategoryDS.categoryName"); parentID.setRootValue("root"); dataSource.setFields(categoryName, parentID); final TreeGrid treeGrid = new TreeGrid(); treeGrid.setWidth(140); treeGrid.setHeight(200); treeGrid.setDataSource(dataSource); // load the top-level nodes into the tree treeGrid.fetchData(new Criteria(), new DSCallback() { public void execute(DSResponse response, Object rawData, DSRequest request) { Tree tree = treeGrid.getTree(); TreeNode root = tree.getRoot(); tree.openFolders(new TreeNode[]{root}); } }); treeGrid.draw(); } }