Services Partners Company
Knowledge Base


Article

How to use recursive data relation with UltraTree

« Go Back

Information

 
EnvironmentProduct: OpenEdge
Version: 10.2x, 11.x
OS: Windows
Question/Problem Description
How to use recursive data relation with UltraTree?
How to display recursive data in UltraTree component?
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution

There are a couple things to remember in order for this to work seamlessly.  An example is provided below that follows these bulleted points:

1) The actual organization of the data for display in the tree is performed during the DATASET's FILL operation; therefore the dataset that is used to feed the tree MUST be filled from some source.  The example demonstrates filling this from a dummy temp-table

2) The query must be filtered on the TOP level or ROOT node

/* Sample */
USING System.Windows.Forms.*.
USING Infragistics.Win.UltraWinGrid.*.

DEFINE VARIABLE oMainForm      AS System.Windows.Forms.Form                      NO-UNDO.
DEFINE VARIABLE oTree          AS Infragistics.Win.UltraWinTree.UltraTree        NO-UNDO.
DEFINE VARIABLE oBindingSource AS Progress.Data.BindingSource                    NO-UNDO.
DEFINE VARIABLE oDrawPt1       AS System.Drawing.Point                           NO-UNDO.
DEFINE VARIABLE oDrawPt2       AS System.Drawing.Point                           NO-UNDO.
DEFINE VARIABLE oDrawSz1       AS System.Drawing.Size                            NO-UNDO.
DEFINE VARIABLE oControls      AS System.Windows.Forms.Control+ControlCollection NO-UNDO.

DEFINE VARIABLE oTopNavQry     AS HANDLE      /* nav query for customer */       NO-UNDO.
DEFINE VARIABLE hDataset       AS HANDLE                                         NO-UNDO.

/* Fake out Data Source */
DEFINE TEMP-TABLE ttDummyEmp NO-UNDO
    FIELD tcEmpName AS CHARACTER
    FIELD tcManager AS CHARACTER
    FIELD tiAge AS INTEGER
    FIELD tcDeptName AS CHARACTER
    INDEX idxEmpName AS UNIQUE tcEmpName.

/* DEFINE A DATASET */
DEFINE TEMP-TABLE ttEmp NO-UNDO
    FIELD tcEmpName AS CHARACTER
    FIELD tcManager AS CHARACTER
    FIELD tiAge AS INTEGER
    FIELD tcDeptName AS CHARACTER
    INDEX idxEmpName AS UNIQUE tcEmpName.

                       
DEFINE DATASET myrecurs FOR ttEmp
    DATA-RELATION r1 FOR ttEmp,ttEmp
                RELATION-FIELDS(tcEmpName,tcManager) RECURSIVE.

DEFINE QUERY qDummy FOR ttDummyEmp.
DEFINE DATA-SOURCE srcDummy FOR QUERY qDummy.

/* Fake out datasource records */
CREATE ttDummyEmp.
ttDummyEmp.tcEmpName = "niel".

CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "dave"
       ttDummyEmp.tcManager = "niel".
      
CREATE ttDum.myEmp.
ASSIGN ttDummyEmp.tcEmpName = "ken"
       ttDummyEmp.tcManager = "niel".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "peter"
       ttDummyEmp.tcManager = "niel".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "martha"
       ttDummyEmp.tcManager = "peter".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "evan"
       ttDummyEmp.tcManager = "martha".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "robin"
       ttDummyEmp.tcManager = "evan".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "rich"
       ttDummyEmp.tcManager = "evan".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "robert"
       ttDummyEmp.tcManager = "martha".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "shelley"
       ttDummyEmp.tcManager = "martha".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "mary"
       ttDummyEmp.tcManager = "ken".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "alex"
       ttDummyEmp.tcManager = "robert".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "jane"
       ttDummyEmp.tcManager = "robert".
      
CREATE ttDummyEmp.
ASSIGN ttDummyEmp.tcEmpName = "sue"
       ttDummyEmp.tcManager = "robert".

BUFFER ttEmp:ATTACH-DATA-SOURCE(DATA-SOURCE srcDummy:Handle).
QUERY qDummy:QUERY-PREPARE("for each ttDummyEmp where tcEmpName = 'niel' ").

DATASET myrecurs:FILL().

DO ON ERROR UNDO, LEAVE:
  oMainForm = NEW System.Windows.Forms.Form().
  oTree = NEW Infragistics.Win.UltraWinTree.UltraTree().

  oDrawPt1 = NEW System.Drawing.Point(0,0).
  oDrawPt2 = NEW System.Drawing.Point(0,0).
  oDrawSz1 = NEW System.Drawing.Size(oDrawPt1).
      
  oDrawSz1:Width = 680.
  oDrawSz1:Height = 480.
  oMainForm:ClientSize = oDrawSz1.

  oDrawPt1:X = 16.
  oDrawPt1:Y = 16.
  oTree:Location = oDrawPt1.
  oTree:TabIndex = 9.
  oDrawSz1:Width = 620.
  oDrawSz1:Height = 424.
  oTree:Size = oDrawSz1.

  oControls = oMainForm:controls.
  oControls:Add(oTree).
   
  hDataset = DATASET myrecurs:HANDLE.

  oTopNavQry = hDataset:TOP-NAV-QUERY(1).
  oTopNavQry:QUERY-PREPARE("preselect each ttEmp where tcEmpName = 'niel' ").
  oTopNavQry:QUERY-OPEN(). 
  
  oBindingSource = NEW Progress.Data.BindingSource(hDataset). 
  oTree:DataSource = oBindingSource.

  WAIT-FOR Application:Run(oMainForm).

  RUN cleanup.
END.

PROCEDURE cleanup:

    IF VALID-OBJECT(oBindingSource) THEN DO:
        oBindingSource:Dispose().
    END.

    REPEAT WHILE SESSION:FIRST-OBJECT <> ?:
        DELETE OBJECT(SESSION:FIRST-OBJECT).
    END.
END.

 

Workaround
Notes
Attachment 
Disclaimer

The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.



Feedback
 
Was this article helpful?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful.



Characters Remaining: 255