PFC Guide Titlebar
HomeFAQLinksPFCMAGExtensionsDownloadWhat's NewSearch

Datawindow Row Manager Service FAQ


Table of Contents

  1. What is the purpose of the row manager service?
  2. When the last row is deleted all rows are deleted.

What is the purpose of the row manager service

Row manager service provides the ability to insert, delete and restore rows. It includes an interface prompting the user to save changes and allowing the selection of deleted rows to be restored. The features of the row manager service are:

-- Insert an empty row between two existing rows, or at the end of a datawindow
-- Delete specific, selected, or all rows
-- Restore one or more deleted rows
-- Require deletions to be confirmed by the end-user
-- Display a pre-built dialog allowing the user to restore one or more deleted rows

 

Back to Top

When the last row is deleted all rows are deleted.

Contributed by Stephen Hauck

Under some conditions, when you select the last row in the datawindow and delete the row manager service deletes all the rows in the datawindow. This happens when the rowfocuschanged event contains

this.SelectRow(0, false)
this.SelectRow(currentrow, true)

or

this.inv_rowselect.of_rowselect(currentrow) 

Solution:

In the service n_cst_dwsrv_rowmanager I overload the function of_deleteselected() with changes to process the array backwards so the row numbers do not change when you delete rows.

//////////////////////////////////////////////////////////////////////////////
//
//	Function: of_DeleteSelected
//
//	Access: Public
//
//	Arguments: none
//
//	Returns: long
//	Number of rows deleted
//	-1 = error
//
//	Description: 
//	Deletes any rows that are selected
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0 Initial version
//
// 10/21/97 Stephen Hauck - Changes noted to support the proper deletion 
of rows
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996 Powersoft Corporation. All Rights Reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Powersoft is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

integer	li_confirm = 1
integer	li_delete
long	ll_rc
long	ll_selectedcount
long	ll_row
long	ll_deletedcount

//Add a loop counter and an array of LONG to hold the row numbers to delete
//10/21/97
LONG ll_counter
LONG ll_rowstodelete[]
//End of new declarations

// Validate requestor DW
if IsNull(idw_requestor) Or not IsValid (idw_requestor) then
return -1
end if

// Determine number of selected rows
ll_row = idw_requestor.GetSelectedRow (0)
do while ll_row > 0
	ll_selectedcount++
	ll_rowstodelete[ll_selectedcount] = ll_row
	ll_row = idw_requestor.GetSelectedRow (ll_row)
loop

// Confirm delete
if ib_confirmondelete then
	li_confirm = of_ConfirmDelete (ll_selectedcount)
end if

// Delete selected rows
if li_confirm = 1 then
	// Prevent redraw slowdown if multiple rows selected
	if ll_selectedcount > 1 then
		SetPointer (hourglass!)
	idw_requestor.SetRedraw (false)
	end if
	ll_row = idw_requestor.GetSelectedRow (0)
	//Comment out the standard PFC code because we do not want a do while 
	loop 
//	10/21/97
//		do while ll_row > 0
//		li_delete = idw_requestor.DeleteRow (ll_row)
//		if li_delete > 0 then
//			ll_deletedcount++
//		else
//			exit
//		end if
//		ll_row = idw_requestor.GetSelectedRow (0)
//		loop
	
	//New for next loop to accomplish the proper deletion of rows
	//10/21/97
	//Process the array backwards so the row numbers do not change when you delete rows.
	FOR ll_counter = ll_selectedcount TO 1 STEP -1
		li_delete = idw_requestor.DeleteRow (ll_rowstodelete[ll_counter])
		if li_delete > 0 then
			ll_deletedcount++
		else
			exit
		end if
	
	NEXT
	//End new for next loop to accomplish the proper deletion of rows

end if

// Turn redraw back on if multiple rows were deleted
if ll_selectedcount > 1 then
	idw_requestor.SetRedraw (true)
end if

return ll_deletedcount
Back to Top

Contributed by PFCGuide staff, except where noted otherwise.
PFCGuide is sponsored by Dynamic Technology Group
The information provided is for advice only and not to be considered a contract or a liability against Dynamic Technology Group.

Last revised: February 15, 2004 03:58 AM.