Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid with sorting capabilities
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00445104
Message ID:
00445108
Views:
12
Thanks Nadia
you are really efficient...!!!


------------------------------------
>Hi
>Im looking for a class (or sample code if any) of how add capabilities for sorting the data in columns of the grid, i've checked the files section but without success.
>
>T.i.a
>Ariel Gimenez

Hi Ariel,

You should create your own Header class and Grid class, which would use this header. Header class should be designed in a program. Check Mike Helland's FAQ #7967684 for some help. You can check Cetin's Basoz MultiSelect grid class here in Files Section, it has this functionality.

The simplest way to sort is to add these lines of code in Grid's Header:

local lcOrder, lnPos
lnPos=rat('.',this.parent.controlsource)
lcOrder=substr(this.parent.ControlSource,lnPos+1)
if tagno(lcOrder)>0 && This index already exists (assume simple indexes tagname=fieldname)
set order to (lcOrder)
else
* You may want to index on this field now - a little dangerous
index on &lcOrder tag (lcOrder)
endif



In our classlib we have a grid, which has a method SetOrder.

LPARAMETERS tcControlSource
LOCAL lnCount, lcField

*-- Sets the order to the currently selected
*-- controlsource if possible

*-- Get the fieldname being used
lcField = ;
SUBSTR(tcControlSource, AT(".", tcControlSource) + 1)

*-- See if the field name is in the leftmost part of the index
*-- expression. If so, SET ORDER TO the index.
FOR lnCount = 1 TO TAGCOUNT()
IF UPPER(SYS(14, lnCount)) = UPPER(lcField)
SET ORDER TO lnCount
IF TYPE("thisform") == "O"
thisform.Refresh()
ENDIF
EXIT
ENDIF
ENDFOR

Ariel Gimenez

our power is our knowledge

Previous
Reply
Map
View

Click here to load this message in the networking platform