Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ReOrder by Column in a Grid
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00199665
Message ID:
00199671
Views:
18
>What would be a good approch to create a grid that will allow the user to click on the header and resort the grid by that column?
>
>Would you create an index on the fly?
>
>Would you not allow a sort on fields like logical?

Here's what we've done, after wrangling with it awhile. Most of grids use a cursor source (but view/table is somewhat similar, so we:

1) make cursors writeable with USE DBF() AGAIN so can index more than once
2) in each column's Moved & Resize events, a flag is set
3) in each header's Click, the flag is checked to make sure the column is not being moved or resized (if they are you don't want a sort).
4) in each header's Click, if flag okay, check to see if index exists
5) if not create one - Ascending for chars, Descending for numeric (use judgement on these)
6) if index exists, set order to it
7) if last order on a column was ascending switch it to descending on current Click, and vice versa - just like Windows Explorer works.
8) Allow sorts on virtually all fields - even logical a user may wish to sort.
9) You may wish to "mark" the current sort order header with color, symbol, etc., though it's not necessary...

Net result is a single header click gets a sort, another single click reverses order. Just like Windows Explorer, as I mentioned, it's nice to keep things standard.

Views & tables are similar, except that you may pre-index them instead, since views require buffering set to row (3) to index, and tables open shared...well you can either pre-index or INDEX...OF C:\tempdir...
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform