|
of_setdatasource
|
|
Full name
|
pfc_u_tv.of_setdatasource
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_setdatasource(integer,string,n_tr,string,string,boolean,integer,integer,integer,integer)
|
Name
|
Datatype
|
lb_First
|
Boolean
|
li_Cnt
|
Integer
|
li_NumDS
|
Integer
|
ls_rc
|
String
|
public function integer of_setdatasource (integer ai_level, string as_datawindow, n_tr atr_obj, string as_labelcolumn, string as_retrieveargs, boolean ab_recursive, integer ai_pictureindex, integer ai_selpictindex, integer ai_statepictindex, integer ai_overlaypictindex);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_SetDatasource
//
// Access: public
//
// Arguments:
// ai_Level The TreeView level to associate the data source with.
// as_DataWindow The DataWindow object to be used for the data source.
// atr_obj The transaction object for this data source (can be
// different for each level).
// as_LabelColumn The column in the DataWindow object to display.
// as_RetrieveArgs Retrieval arugments for the DataWindow. These should
// be separated by commas in the format:
// :keyword.n.column
// where column is the name of a column in another level's
// data source. If keyword is 'level', n is an absolute level
// number. If keyword is 'parent', n is a number relative to
// the current level (i.e. :parent.2.c1 would be column c1 in
// the DataWindow for the level 2 levels above this one.
// ab_Recursive True - indicates that this is the last data source for this tree.
// It will be used recursively for each subsequent level.
// ai_PictureIndex The index to the picture array to use for this level.
// ai_SelPictIndex The index to the picture array to use for the selected picture for
// this level.
// ai_StatePictIndex The index to the picture array to use for the state picture for
// this level.
// ai_OverlayPictIndex The index to the picture array to use for the overlay picture for
// this level.
//
// Returns: integer
// 1 = the data source was added successfully
// -1 = argument validation error
// -2 = the DataWindow object did not have any key columns assigned
// -3 = a previous level had already been marked as recursive (there can be no more)
// -4 = column label datatype was not a string
// -5 = The transaction object could not be set
//
// Description: Register a data source for a level of the TreeView. The data source is a
// DataWindow object that will be linked to the TreeView level and used
// to populate.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Add Check to verify label datatype as string and new return code (-4)
// 6.0.01 Call of_settransobject on datastore rather than settransobject
// 6.0.01 Add code to check rc from settransobject (-5) and if
// column label is in datasource (-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_NumDS, li_Cnt
Boolean lb_First
String ls_rc
// Check arguments
if IsNull (ai_level) or ai_level <= 0 or &
Len (as_datawindow) = 0 or IsNull (as_datawindow) or &
IsNull (atr_obj) or not IsValid (atr_obj) or &
IsNull (as_labelcolumn) or IsNull (as_retrieveargs) or &
IsNull (ab_recursive) or IsNull (ai_pictureindex) or IsNull (ai_selpictindex) or &
IsNull (ai_statepictindex) or IsNull (ai_overlaypictindex) then
return -1
end if
// Check if recurrsive is being used
li_NumDS = UpperBound(inv_ds)
If li_NumDS > 0 Then
If inv_ds[li_NumDS].b_Recursive Then
// If the last one is recursive, there can be no more
Return -3
End if
End if
// Set values in the attribute class array
inv_ds[ai_Level].s_DataWindow = as_DataWindow
inv_ds[ai_Level].s_LabelColumn = as_LabelColumn
inv_ds[ai_Level].s_RetrieveArgs = as_RetrieveArgs
inv_ds[ai_Level].b_Recursive = ab_Recursive
inv_ds[ai_Level].i_PictureIndex = ai_PictureIndex
inv_ds[ai_Level].i_SelectedPictureIndex = ai_SelPictIndex
inv_ds[ai_Level].i_StatePictureIndex = ai_StatePictIndex
inv_ds[ai_Level].i_OverlayPictureIndex = ai_OverlayPictIndex
// Create a DataStore to use as the data source
If IsNull(inv_ds[ai_Level].ds_obj) Or Not IsValid(inv_ds[ai_Level].ds_obj) Then
inv_ds[ai_Level].ds_obj = Create n_ds
inv_ds[ai_Level].ds_obj.of_SetBase(true)
End if
// Set parameters for the DataStore
inv_ds[ai_Level].ds_obj.of_SetAppend(True)
inv_ds[ai_Level].ds_obj.DataObject = as_DataWindow
inv_ds[ai_Level].tr_obj = atr_obj
// make sure transaction object is valid
If inv_ds[ai_Level].ds_obj.of_SetTransObject(atr_obj) <> 1 Then
inv_ds[ai_Level].s_DataWindow = ""
Destroy inv_ds[ai_Level].ds_obj
Return -5
End if
// label column must be in the datawindow
If inv_ds[ai_Level].ds_obj.Describe(as_LabelColumn + ".Band") = "!" Then
inv_ds[ai_Level].s_DataWindow = ""
Destroy inv_ds[ai_Level].ds_obj
Return -4
End if
// verify column label datatype as string
ls_rc = inv_ds[ai_Level].ds_obj.describe(as_LabelColumn + ".ColType")
if lower(left(ls_rc,4)) <> "char" then
inv_ds[ai_Level].s_DataWindow = ""
Destroy inv_ds[ai_Level].ds_obj
Return -4
End if
// Add a computed column to the DataWindow object that will
// contain all the keys concatenated together. This is necessary
// to be able to find a unique row.
If of_CreateKey(inv_ds[ai_Level].ds_obj) = -1 Then
// No key columns were defined
inv_ds[ai_Level].s_DataWindow = ""
Destroy inv_ds[ai_Level].ds_obj
Return -2
End if
// Determine if this is recursive
If ai_Level < li_NumDS And ab_Recursive Then
// Remove all below this one because it is recursive
For li_Cnt = (ai_Level + 1) To li_NumDS
inv_ds[ai_Level].s_DataWindow = ""
Next
End if
Return 1
end function