|
of_deleteitem
|
|
Full name
|
pfc_n_cst_tvsrv_levelsource.of_deleteitem
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_deleteitem(long)
|
Name
|
Datatype
|
lds_source
|
n_ds
|
li_confirm
|
Integer
|
li_rc
|
Integer
|
ll_row
|
Long
|
ltvi_Item
|
TreeViewItem
|
public function integer of_deleteitem (long al_handle);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_DeleteItem
//
// Access: public
//
// Arguments:
// al_Handle The handle of the item to be delete.
//
// Returns: Integer
// 1 - the item was deleted successfully
// 0 - nothing deleted - cancelled
// -1 - an error occurred
//
// Description: Delete an item from the TreeView. The item's row will be
// DELETED from its DataStore (the user must call the Update(),
// however).
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 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_confirm, li_rc
Long ll_row
TreeViewItem ltvi_Item
n_ds lds_source
// validate references
If IsNull(itv_requestor) or Not IsValid(itv_requestor) Then Return -1
If itv_requestor.GetItem(al_handle, ltvi_item) <> 1 Then Return -1
// ask for confirmation if it is needed
if of_ConfirmOnDelete() then
li_confirm = of_ConfirmDelete(1)
// Delete item if = 1
if li_confirm <> 1 then return 0
End If
// this may take some time if all children are not retrieved
// aka cascade delete
setpointer(hourglass!)
//turn off redraw for performance
itv_requestor.setredraw(false)
// automatically populate all children
itv_requestor.expandall(al_handle)
// Remove the item's children
If of_RemoveChildren(al_Handle) = -1 Then Return -1
If of_GetDataRow(al_handle, lds_source, ll_row) <> 1 Then
// row is already deleted from datastore
Return -1
End If
// only need to delete the row
lds_Source.DeleteRow(ll_Row)
// Get the parent and previous handle (for undo capability)
If ib_undo Then
il_UndoDeleteParentHandle = itv_requestor.FindItem(ParentTreeItem!, al_handle)
il_UndoDeleteHandle = itv_requestor.FindItem(PreviousTreeItem!, al_handle)
itvi_UndoDeleteItem = ltvi_Item
is_UndoType = UNDO_DELETE
End If
// hide the children and then delete the item
itv_requestor.collapseitem(al_handle)
li_rc = itv_requestor.DeleteItem(al_Handle)
// turn back on redraw
itv_requestor.setredraw(true)
// return code of deleteitem call
return li_rc
end function