Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I stop headers click in mouseup event?
Message
From
20/08/2001 13:23:53
 
 
To
20/08/2001 12:39:13
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00546254
Message ID:
00546313
Views:
15
Christian-

>1. the headers should sort the columns of the grid when clicked, but not when moved or resized, but they should be move- and resizable

Just a comment. I was doing a set order in a grid header click, too. I just got a bug report from a user this week that whenever they were resizing the sorting fired which was annoying (understandably so). I solved it by putting the sort option in a right click popup menu, which I already had for the header.

You might consider it. It's a much cleaner implementation, IMO, so easier to maintain. I haven't gotten the blessing from the users yet, though.

Here's a snippet of my code:
*       *********************************************************
*       *
*       * 07/30/00         PREVIEWCHECKBOX.MPR          10:03:12
*       *
*       *********************************************************
LPARAMETER toColumn
DEFINE POPUP shortcut shortcut RELATIVE FROM MROW(),MCOL()
DEFINE BAR 7 OF shortcut PROMPT "Sort"
ON SELECTION BAR 7 OF shortcut SortBy( toColumn )

ACTIVATE POPUP shortcut

	*!* 2001.08.19 nf FUNCTION SortBy. Moved this functionality from the header
	*!* click() method to avoid conflicts with resizing the columns
	FUNCTION SortBy(toColumn)
		*!* First see if we already have a tag for this column
		LOCAL lnTags, loGrid, lcAlias, lnRecno, lvValue, loHeader
		PRIVATE plSuccess, lcExpr
		plSuccess = .T.
		lcExpr = JUSTEXT( tocolumn.CONTROLSOURCE )
		*!* 2001.03.07 NF 4: Added protection on strings too long to index
		lvValue = EVALUATE(  lcExpr )
		IF VARTYPE( lvValue ) = "C" .AND. LEN( lvValue ) > 240
			lvValue = "LEFT(" + lcExpr + ",240)"
		ELSE
			lvValue = lcExpr
		ENDIF
		FOR EACH loHeader IN toColumn.Controls
			IF LOWER( loHeader.BaseClass ) = "header"
				EXIT
			ENDIF
			*!* If we don't find a header, we're stuck. But that would be unlikely since
			*!* the intention of this PRG is to be run from the rightclick of a header.
		NEXT lni
		loGrid = toColumn.PARENT
		lcAlias = loGrid.RECORDSOURCE
		lnTags = TAGCOUNT( lcAlias )
		SELECT (lcAlias) && Yes, it should be active, but just in case
		lnRecno = RECNO()
		IF loHeader.FONTBOLD
			IF DESCENDING()
				lcExpr = "INDEX ON " + lvValue + " TAG " + SUBSTR( lcExpr, 1, 10 ) + " ASCENDING"
			ELSE
				lcExpr = "INDEX ON " + lvValue + " TAG " + SUBSTR( lcExpr, 1, 10 ) + " DESCENDING"
			ENDIF
			&lcExpr
		ELSE
			lcExpr = "INDEX ON " + lvValue + " TAG " + SUBSTR( lcExpr, 1, 10 ) + " ASCENDING"
			&lcExpr
			loGrid.SETALL( 'FontBold', .F. )
			*!* 2001.03.07 nf 3: If the indexing wasn't successful, don't bold the header.
			IF plSuccess .AND. !EMPTY(ORDER())
				loHeader.FONTBOLD = .T.
			ENDIF
		ENDIF
		loGrid.REFRESH()
		LOCAL lcOrder
		lcOrder = ORDER()
		WITH loGrid.PARENT.Label2
			.CAPTION = "Sorted by " + loHeader.CAPTION + IIF( DESCENDING(), ' (descending).', ' (ascending).' )
			.VISIBLE = .NOT. EMPTY( lcOrder )
		ENDWITH
		GOTO lnRecno
	ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform