Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programmatically sort a table
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00465022
Message ID:
00465041
Vues:
16
Hi!

Following is usual algorithm:

-Remember the current record number (RECNO()) in the grid cursor.
-Use INDEX command to index the cursor used to display grid content.
-Use 'Locate for .F.' to move record pointer to the top of grid. Use locate for this for better performance
-Refresh grid
-Set record pointer back to the previous position remembered in the first step
-refresh grid again or set focus to the column which used for sorting.

Do all above using thisform.LockScreen property to avoid screen flickering.

INDEX command is quite complex, so investigate the best approach that is sutable for you. The most universal way is to use standalone CDX file with temporary name:
thisform.cTempTagName = left("T" + sys(3),8)
INDEX ON SomeField TAG (thisform.cTempTagName) OF (thisform.lcTempTagName) ADDITIVE

To remove sorting, use SET INDEX OFF, than clean up temporary index file using ERASE command (note that you will require to remember temporary name for that in the cTempTagName property of form):
ERASE (thisform.cTempTagName + ".CDX")


HTH.

>Hi to All
>Does anyone know how to sort a table programmatically?
>More specifically:
>We need to sort the contents of a grid by date when the user initializes a form and when a change has been made (refresh).
>We have already tried doing the sort through the data environment for the table but it does not work .
>any recomendations?
>Thanking you in advance
>Regards
>mike
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform