Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid row change doesn't update field values?
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Grid row change doesn't update field values?
Divers
Thread ID:
00302018
Message ID:
00302018
Vues:
54
I've discovered an undesirable behavior when changing from one row to the next in a grid of child relationships. Can anyone tell me why?

This is an order entry screen. I want to validate the order item row (especially for the quantity and size fields) when the user leaves the row. I'm using Cetin Basoz' row change detection routine (Thanks, Cetin!), then checking for missing data. The AllowAddNew property for the grid is .T.

I found that if the user adds a row with new data (or even tabs through the row), the routine behaves as expected. However, if the user presses the down key more than once, the validation routine doesn't get triggered, and multiple empty item rows are created. (NOT desired!)

Writing values to the screen revealed that when the new row is appended, the values for the comboboxes still reflect the last row containing data instead of being empty, as I would expect.

What am I overlooking? Or am I doing something wrong here?

In the BeforeRowColChange event I have:
LPARAMETERS nColIndex

llChangingRow =.F.

WITH this
IF mdown()			
lnBottom = .top+.headerheight+.relativerow * .rowheight		
lnTop = lnBottom - this.rowheight			
lnMouseRowPos = mrow(wontop(),3)			
lnMouseColPos = mcol(wontop(),3)			
llChangingRow = !(between(lnMouseRowPos,lnTop, lnBottom) ;
and between(lnMouseColPos,.left,.left+.width))		
* Is click on a different row
ELSE
llChangingRow = inlist(lastkey(),24,5,18,3)
* Was lastkey() in Up,down, pgup,pgdown
ENDIF
ENDWITH



*!*	* Check for missing SIZE or QUANTITY fields
IF  llChangingRow = .T.
DO CASE
	CASE EMPTY(This.grcDescript.grcboDescript.value)
		NODEFAULT

	CASE This.grcQty.grtxtQty.value = 0			&& Has the user forgotten to enter the quantity?
		MESSAGEBOX("Please enter the desired quantity.",MB_ICONEXCLAMATION + MB_OK,"Required information missing.")
		THIS.grcQty.grtxtQty.SETFOCUS()
		nodefault

	CASE empty(This.grcSize.grCboSize.value)		&& Has the user forgotten to enter the size?
		IF NOT EMPTY(ggproducts.sizes)		&& do sizes exist for this item?
			MESSAGEBOX("Please enter the desired Size.",MB_ICONEXCLAMATION + MB_OK,"Required information missing.")
			THIS.grcSize.grCboSize.SETFOCUS()
			nodefault
		ENDIF
	OTHERWISE
		ACTIVATE SCREEN
			? 'llChangingRow = ', llChangingRow, 'Value = ',This.grcDescript.grcboDescript.value,;
		   'Qty = ',This.grcQty.grtxtQty.value, 'Size = ',This.grcSize.grCboSize.value
ENDCASE
ENDIF
RETURN
In the AfterRowColChange event, I have:
LPARAMETERS nColIndex
LOCAL lnNewRec, lnOrderID, lnItem, lnOldArea


* When new row added, fill in Order ID and Line_ID in OrderItems table
IF orderitems.order_id <1		&& New item?
	lnNewRec = recno('orderitems')
* (NewID function creates orderitem.key value)
	lnOrderID= orders.order_id
	REPLACE orderitems.order_id WITH lnOrderID		&& fill in order ID
	lnItem=1									&& Find last item #
	LOCATE FOR orderitems.order_id=lnOrderID .AND. orderitems.line_id=lnItem
	DO WHILE FOUND()
		lnItem=lnItem+1
		CONTINUE
	ENDDO
	GOTO (lnNewRec)         
	REPLACE orderitems.line_id WITH lnItem			&& Insert item number in new record
ENDIF
THISFORM.REFRESH()
		ACTIVATE SCREEN           && Debugging - display values
		? 'Record = ', recno(), 'Value = ',This.grcDescript.grcboDescript.value,;
		   'Qty = ',This.grcQty.grtxtQty.value, 'Size = ',This.grcSize.grCboSize.value
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform