Announcement

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

    Advice/help with TreeGrid needed

    I'm using SC_SNAPSHOT-2011-01-04/PowerEdition Deployment.

    I've read TreeDataBinding documentation and I'm struggling to get a TreeGrid to work the way I'd like. I think I'm missing something fundmental in my understanding.

    I have a view in a OPS_TREE.ds.xml defined as follows:

    Code:
    <DataSource
    	schema="ADENT"
    	dbName="adme4" 
    	tableName="OPS_TREE" 
    	ID="OPS_TREE" 
    	serverType="sql" 
    >
    	<fields>
    		<field name="hq_id" type="number" primaryKey="true" />
    		<field name="hq_name" type="text" />
    		<field name="machine_id" type="number" parentId="hq_id"/>
    		<field name="machine_name" type="text" />
    		<field name="zone_id" type="number" parentId="machine_id"/>
    		<field name="zone_name" type="text" />
    		<field name="network_id" type="number" parentId="zone_id"/>
    		<field name="network_name" type="text" />		
    	</fields>
    </DataSource>
    Each record is a completely extended node in the tree. So, example data:

    Code:
    SQL> select * from ops_tree;
    
         HQ_ID HQ_NAME MACHINE_ID MACHINE_NA    ZONE_ID ZONE_NAME  NETWORK_ID NETWORK_NA
    ---------- ------- ---------- ---------- ---------- ---------- ---------- ----------
             2 wally            2 adslim              1 S01                 1 CH01
             2 wally            2 adslim              1 S01                 2 CH02
             2 wally            2 adslim              1 S02                 2 CH01
             2 wally            2 adslim              1 S02                 2 CH02
             3 eddie            2 adtst               1 T01                 1 CH01
             3 eddie            2 adtst               1 T01                 2 CH02
             3 eddie            2 adtst               3 T02                 1 CH01
             3 eddie            2 adtst               3 T02                 2 CH02
             3 eddie            2 adtst               5 T03                 1 CH01
             3 eddie            2 adtst               5 T03                 2 CH02
             3 eddie            4 adhuy               2 H01                 1 CH01
             3 eddie            4 adhuy               2 H01                 2 CH02
    What I'd like to do is have HQs 'wally' and 'eddie' be at one top level of the tree. Then under 'wally' have 'adslim' with the next node then having 'S01' and 'S02'. Then the final nodes off of 'S01' be 'CH01' and 'CH02' (the same would be the case for 'S02'). A similar tree would be off of HQ 'eddie'.


    Any advice on how to tag my OPS_TREE.ds.xml correctly would be appreciated. Do I need to have the *_NAME fields all be named the same for them to display correctly in a tree? Or, do I need to model the data differently? The tree is to display unlike elements at the various nodes (e.g. HQ->machine->zone->network). Or, do I have to build the Tree manually node by node? Or, something else entirely?

    #2
    On the name attributes, you can either copy all the different possible name attributes to a single property, or you can implement TreeGrid.getNodeTitle() and handle the differences there.

    As far as the tree structure, you want to use the parent-linked model, where each record has a unique id and a parentId pointing to it's parent in the tree. You basically want to add a DMI that creates a single, uniform id and parentId field, possibly by concatenating strings. For example, your IDs might be of the form "hqId:actual HQ Id", "machine_id:actual machine id" and so forth.

    Comment

    Working...
    X