Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TreeGrid with empty folders when getting data from DataSource

    Hello all,

    While using SmartGWT 2.2.0 I'm trying to implement a TreeGrid, which takes data from DataSource and has the possibility to reparent itself, and add nodes even to leaves.

    Can you help me with a way of doing that?

    Here is my code
    Code:
                    final TreeGrid groupStructureTree = new TreeGrid();
    		
    		groupStructureTree.setCanEdit(true);
    		groupStructureTree.setLoadDataOnDemand(false);
    		groupStructureTree.setWidth(500);
    		groupStructureTree.setHeight(400);
    		groupStructureTree.setDataSource(dataSource);
    		groupStructureTree.setAutoFetchData(true);
    		groupStructureTree.setFolderIcon("icons/person.png");
    		groupStructureTree.setNodeIcon("icons/person.png");
    		groupStructureTree.setClosedIconSuffix("");
    		groupStructureTree.setShowOpenIcons(false);
    		groupStructureTree.setCanReorderFields(false);
    		groupStructureTree.setCanReparentNodes(true);
    		groupStructureTree.setCanDropOnLeaves(true);
    
    		TreeGridField parentName = new TreeGridField("g2g_id", "Name1");
    	        parentName.setOptionDataSource(DataSource.get("listing_groups"));
    		parentName.setDisplayField("group_name");
    		parentName.setValueField("group_id");
    		
    
    		groupStructureTree.setFields(parentName);
    and my datasource
    Code:
    <DataSource ID="g2g" serverType="sql" tableName="g2g">
    	<fields>
    		<field name="g2g_id" type="integer" hidden="true" primaryKey="true" />
    		<field name="g2g_record_group_id" type="integer" />
    		<field name="g2g_parent_group_id" 
    			   type="integer" 
    			   foreignKey="g2g.g2g_id"  
    			   rootValue="1"/>
    	</fields>
    	<operationBindings>
    		<operationBinding operationType="fetch">
    			<tableClause>g2g</tableClause>
    			<whereClause>($defaultWhereClause)</whereClause>
    		</operationBinding>
    	</operationBindings>
    </DataSource>
    Thank you in advance,
    Angel
    Last edited by Driftdone; 11 Jul 2011, 00:47.
Working...
X