Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Controlling sorting in a grid.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00369438
Message ID:
00369567
Vues:
18
Hi Joe,

We have this method SetOrder for our Grid class. In a header.Click() just invoke this.parent.parent.SetOrder(). It's not necessary to specify parameter.
LPARAMETERS tcControlSource
LOCAL lnCount, lcField
*--------------------------------------------------------------------------
* -- NSL 2/29/00 Added the following IF per request of Nadya
* -- If field is not passed, default to the active column.
*--------------------------------------------------------------------------
IF EMPTY(tcControlSource) && User doesn't provide a field name
   tcControlSource=this.ActiveColumn.ControlSource
ENDIF

*-- 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
          this.refresh()
    EXIT
  ENDIF
ENDFOR
>I have a grid set up that is showing fields from a view. I want to be able to sort the grid by clicking the header. I hate
>to hard code the field name in each header click method but here is what I have come up with.
>
>if sys(22) <> 'PARTNO' then
> index on partno tag partno
>else
> set order to partno
>endif
>thisform.refresh
>
>The next header would have 'DESCRIPTION' instead of partno.
>
>I figured by creating the index in the click method I save processing by not creating indexes that will never
>get used. Does it make sense to do it this way?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform