Konu: filtering-choices In Grid
Foxite de gordum paylasmak istedim arsivinizde bulunsun
Visual Fox Pro
*!* Author Cetin BASOZ
*!*! http://www.foxite.com/archives/filtering-choices-0000280991.htm
Public oForm
oForm = Createobject("sampleForm")
oForm.Show()
Define Class sampleForm As Form
DataSession=2
Height=600
Width=800
BindControls=.F.
Add Object myGrid As Grid With Height = 400,Width=800,RecordSource=''
Add Object lstFilters As ListBox With Left=10,Top=410,Height=180,Width=200,;
RowSourceType=3,RowSource='Select * from myFilters into cursor crsFilters'
Add Object btnFilterData As CommandButton With Top=450, Left=220,;
AutoSize=.T., Caption='Apply Filter'
Procedure Load
Create Cursor MyFilters (Description c(100), whereClause m)
Insert Into MyFilters Values ("No Filter","")
Insert Into MyFilters Values ("Country is 'USA'","where UPPER(Country) == 'USA'")
Insert Into MyFilters Values ("Title starts with 'Sales'","where UPPER(Title) like 'SALES%'")
Insert Into MyFilters Values ("Purchase amount is over 30,000$","where MaxOrdAmt > 30000")
Endproc
Procedure Init
This.filterData('')
This.BindControls = .T.
Endproc
Procedure filterData(tcWhere)
Local lcWhere
lcWhere = Evl(m.tcWhere,'')
This.myGrid.RecordSource=''
Select cust_id,Company,contact,Title,country,maxordamt ;
FROM (_samples+'data\customer') ;
&lcWhere ;
INTO Cursor crsCustomers ;
readwrite
This.myGrid.RecordSource='crsCustomers'
Endproc
Procedure btnFilterData.Click
If Thisform.lstFilters.ListIndex = 0
Thisform.filterData('')
Else
Thisform.filterData(crsFilters.whereClause)
Endif
Endproc
Enddefine