PreviousNextIndex

CURRENT-QUERY( ) method

The handle to the ProDataSet query that contains the currently selected row in the ProBindingSource. This method enables access to the correct child query when a bound .NET grid edits, creates, or deletes a row from a child table.

Use this method when the .NET control is bound to a ProDataSet object that contains child buffers.

Data type: HANDLE

Access: Readable

Applies to: Data-relation object handle

Syntax
CURRENT-QUERY( [ INPUT band-index AS INTEGER ] ) 

band-index

When a .NET control binds to a ProBindingSource that uses a ProDataSet as its data source object, multiple relations for the same parent-child relationship might be presented to the user simultaneously. When the user first expands a parent row in the bound .NET control, the ProBindingSource creates a new child query and displays all child rows for that parent row. The ProBindingSource uses the ProDataSet object’s data-relation query to create and maintain this unique query for all child rows related to the expanded parent row.

Note: You cannot set this query handle or modify the query.

The following code fragment shows an event handler. The event handler accepts information from a bound UltraWinGrid displaying Order and Orderline data through the grid’s extended version of the .NET System.EventArgs class. From that information, the event handler can find the correct query for the currently selected record.

DEFINE VARIABLE hDataSet AS HANDLE NO-UNDO. 
... 
PROCEDURE BeforeRowUpdate: 
  DEFINE INPUT PARAMETER sender AS System.Object         NO-UNDO. 
  DEFINE INPUT PARAMETER args   AS 
    Infragistics.Win.UltraWinGrid.CancelableRowEventArgs NO-UNDO. 
  DEFINE VARIABLE cBufferName AS CHARACTER NO-UNDO. 
  DEFINE VARIABLE hRelation   AS HANDLE    NO-UNDO. 
  DEFINE VARIABLE hQuery      AS HANDLE    NO-UNDO. 
  cBufferName = args:Row:Band:Key. 
  IF cBufferName EQ "ttOrder" THEN 
    ASSIGN 
      hRelation = hDataSet:GET-RELATION(1) 
      hQuery    = hRelation:CURRENT-QUERY. 
  END. 
  ELSE IF cBufferName EQ "ttOrderLine" THEN 
    ASSIGN 
      hRelation = hDataSet:GET-RELATION(2) 
      hQuery    = hRelation:CURRENT-QUERY. 
  END. 
END PROCEDURE. 

When a ProBindingSource is attached to a ProDataSet with a recursive data-relation, the code above does not work because a single buffer is associated with multiple BandIndexes in a hierarchical grid. The event handler must specify the BandIndex of the current row to determine the correct query.

The following example shows a similar event handler using the optional parameter. Because an employee might also be a manager and have employees of his own, dsRecursive has a recursive data-relation between EmpName and Manager. For the top band of the hierarchy, the event handler can use the TOP-NAV-QUERY. For lower bands, it needs the optional parameter to determine the correct query.

DEFINE TEMP-TABLE ttEmp NO-UNDO  
  BEFORE-TABLE ttEmpB 
  FIELD EmpName    AS CHARACTER  
  FIELD Manager    AS CHARACTER 
  FIELD HireDate   AS INTEGER 
  INDEX idxEmpName AS UNIQUE EmpName. 
                         
DEFINE DATASET dsRecursive FOR ttEmp  
  DATA-RELATION r1 FOR ttemp, ttemp 
  RELATION-FIELDS(EmpName,Manager) RECURSIVE. 
   
DEFINE VARIABLE hRelation AS HANDLE NO-UNDO. 
DEFINE VARIABLE hTopQuery AS HANDLE NO-UNDO. 
... 
PROCEDURE BeforeRowUpdate: 
  DEFINE INPUT PARAMETER sender AS System.Object         NO-UNDO.  
  DEFINE INPUT PARAMETER args   AS 
    Infragistics.Win.UltraWinGrid.CancelableRowEventArgs NO-UNDO. 
  DEFINE VARIABLE bandIndex     AS INTEGER               NO-UNDO. 
  DEFINE VARIABLE hQuery        AS HANDLE                NO-UNDO. 
  ASSIGN 
    bandIndex = args:Row:Band:Index 
    hRelation = DATASET dsRecursive:GET-RELATION(1). 
  IF bandIndex EQ 0 THEN 
    hQuery = hTopQuery. 
  ELSE IF bandIndex > 0 THEN 
    hQuery = hRelation:CURRENT-QUERY(bandIndex). 
END PROCEDURE. 

See also: BandIndex property


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex