Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple Sortable/Filterable grid
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01382508
Message ID:
01382593
Vues:
49
I use these 2 classes to deal with the sorting. They work great.
Define Class grdColumn As Column
	FontSize = 8
	BackColor = Rgb(255,255,255)
	ForeColor = Rgb(0,0,0)
  	HeaderClass="ColHeader"
	HeaderClassLibrary="gridclasslib.prg"
Enddefine


Define Class ColHeader As Header
	FontSize = 8
	BackColor = Rgb(236,233,216)
	ForeColor = RGB(255,255,255)
	
		
  Procedure Click
  	Local lcAlias
    * Sets the Order for a Table Alias when clicked.
    *IMPORTANT:
    * This method assumes that an index tag has been created for each column of the grid
    * AND that the tag is named identically to the field name for the column.
    Private all
    
    **- Need to test the controlsource has an alias
    lcAlias = (Juststem(This.Parent.ControlSource))
    If Used(lcAlias) 
	    Select (Juststem(This.Parent.ControlSource))
	    fieldname = Upper(Justext(This.Parent.ControlSource))
	    
	    If Len(fieldname) > 10
	    	fieldname = Left(fieldname, 10)
	    EndIf
	    
	    Do Case
	   	Case TagNo(m.fieldname)>0 AND (Tag()#m.fieldname OR Descending())
	      Set Order To (m.fieldname) Ascending
	      If PemStatus(ThisForm, "lDescending", 5)
	      	  ThisForm.lDescending = .F.
	      EndIf
	      If PemStatus(ThisForm, "cSortOrder", 5)
	      	  ThisForm.cSortOrder = fieldname
	      EndIf
	      
	    Case TagNo(m.fieldname)>0
	      Set Order To (m.fieldname) Descending
	      If PemStatus(ThisForm, "lDescending", 5)
	      	  ThisForm.lDescending = .T.
	      EndIf
	      If PemStatus(ThisForm, "cSortOrder", 5)
	      	  ThisForm.cSortOrder = fieldname
	      EndIf

	    EndCase
	    Goto Top
	    Thisform.Refresh
	EndIf
  EndProc
Enddefine
Now on you grid control set the MemberClass to grdColumn (navigate to the prg and select the grdColumn class)

This relies on the fields you want to sort on to have a sorting tag with the same name.

regards


>(Not sure if the attachment will work, but going to give it a try.)
>
>I found that to create a grid that one could sort, filter etc became quite cumbersome so I developed this simple class where all I have to do is assign the grids recordsource and enter the select statement in the custom method "m_select_clause".
>
>to identify the headers, I assigned the property "p_header_label"
>
>By doing double click in a cell to filter, right click to clear and sort by clicking in header.
>
>What I would be interested is suggestions that would make this class better and more usefull. (and in fact if it works for anyone else)
>
>Thanks in advance
>
>(i guess i can not add the zip file with out a subscription. if anyone interested, i will email)
Mathias Banda

Time is longer than a rope.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform