|
of_populatelevel
|
|
Full name
|
pfc_u_tv.of_populatelevel
|
Access
|
protected
|
Extend of
|
long
|
Return value
|
long
|
Prototype
|
protected function long of_populatelevel(integer,long)
|
Name
|
Datatype
|
la_Arg
|
Any[20]
|
li_Index
|
Integer
|
ll_Cnt
|
Long
|
ll_NewRows
|
Long
|
ll_Rows
|
Long
|
ltvi_New
|
TreeViewItem
|
protected function long of_populatelevel (integer ai_level, long al_parent);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_PopulateLevel
//
// Access: protected
//
// Arguments:
// ai_Level The TreeView level to be populated.
// al_Parent The handle of the parent TreeView item that is being populated.
//
// Returns: long
// Returns # of rows added successfully,
// -1 if an error occurrs.
// -2 no key columns defined on data source object
// -3 Retrieve failed
// -4 dw object does not exist - of_setdatasource probably failed
// -5 Setting the transaction object failed
//
// Description: Populate a TreeView item with its child items.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Fix null object reference error on non-updateable datawindows
// and add a new return code (-2).
// 6.0.01 Call of_settransobject on datastore rather than settransobject
// 6.0.01 Add code to check rc from settransobject (-5) and retrieve (-3)
// and non-updateable check on key creation (-2)
// 6.0.01 Change Return codes to match those from of_setdatasource (was -2 (5.03) is now -4)
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1999 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
Integer li_Index
Long ll_NewRows, ll_Rows, ll_Cnt
Any la_Arg[20]
TreeViewItem ltvi_New
SetPointer(Hourglass!)
// Determine if the level is recursive
If ai_Level > UpperBound(inv_ds) Then
li_Index = UpperBound(inv_ds)
Else
li_Index = ai_Level
End If
// check datawindow object for existence. This is set to ""
// in of_setdatasource() when the datawindow is not updateable
if inv_ds[li_Index].s_DataWindow = "" then
return -4
end if
// Get retrieval arguments
If al_Parent > 0 Then
of_GetArgs(al_Parent, ai_Level, la_Arg)
// Retrieve the rows into the temporary buffer
ids_Buffer.Reset()
ids_Buffer.DataObject = inv_ds[li_Index].s_DataWindow
// Need to connect ok before we do a retrieve
If ids_Buffer.of_SetTransObject(inv_ds[li_Index].tr_obj) <> 1 Then Return -5
ll_NewRows = ids_Buffer.Retrieve(la_Arg[1], la_Arg[2], la_Arg[3], la_Arg[4], la_Arg[5], &
la_Arg[6], la_Arg[7], la_Arg[8], la_Arg[9], la_Arg[10], &
la_Arg[11], la_Arg[12], la_Arg[13], la_Arg[14], la_Arg[15], &
la_Arg[16], la_Arg[17], la_Arg[18], la_Arg[19], la_Arg[20])
Else
ll_NewRows = ids_Buffer.RowCount()
End if
// was the retrieve successful?
If ll_NewRows < 0 Then Return -3
// Append the rows to the level's DataStore
ll_Rows = inv_ds[li_Index].ds_obj.RowCount()
ids_Buffer.RowsCopy(1, ll_NewRows, Primary!, inv_ds[li_Index].ds_obj, (ll_Rows + 1), Primary!)
// Clear the status flags for the new rows
For ll_Cnt = (ll_Rows + 1) To (ll_Rows + ll_NewRows)
inv_ds[li_Index].ds_obj.SetItemStatus(ll_Cnt, 0, Primary!, DataModified!)
inv_ds[li_Index].ds_obj.SetItemStatus(ll_Cnt, 0, Primary!, NotModified!)
Next
// Add key column to the DataStore. This will be set in the Data attribute of the TreeView item
If of_CreateKey(ids_Buffer) = -1 Then
// No key columns were defined or non-updateable dw
Return -2
End if
// Add nodes to the TreeView
For ll_Cnt = 1 To ll_NewRows
If of_SetItemAttributes(li_index, ids_Buffer, ll_Cnt, ltvi_New) = -1 Then Return -1
If UpperBound(inv_ds) > ai_Level Or inv_ds[li_Index].b_Recursive Then
ltvi_New.Children = True
Else
ltvi_New.Children = False
End if
This.InsertItemLast(al_Parent, ltvi_New)
Next
Return ll_NewRows
end function