#include "fivewin.ch"
REQUEST DBFCDX
function Main()
local oDlg, oBrw
local cFilter := ""
local aFilters := { { .f., "AGE>40" }, { .f., "STATE='NY'" }, { .f., "MARRIED" } }
local aCheck[ 3 ], n
local nRow := 40
local nCol := 40
local oDbf
oDbf := TDataBase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL
for n := 1 to Len( aFilters )
aCheck[ n ] := CreateChk( nRow, nCol, oDlg, aFilters, n, oDbf, @cFilter )
aCheck[ n ]:lTransparent := .t.
nCol += 150
if n == 3
EXIT
endif
next
@ 80, 40 SAY { || "FILTER : " + cFilter } SIZE 400, 25 PIXEL OF oDlg CENTER UPDATE
@ 115, 40 XBROWSE oBrw SIZE -40,-40 PIXEL OF oDlg ;
DATASOURCE oDbf;
COLUMNS "ID", "CITY", "STATE", "MARRIED", "AGE" ;
CELL LINES NOBORDER UPDATE
oBrw:SetChecks()
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
return nil
static function CreateChk( nRow, nCol, oDlg, aFilters, nIndex, oDbf, cFilter )
local oChk
@ nRow, nCol CHECKBOX oChk VAR aFilters[ nIndex, 1 ] ;
PROMPT aFilters[ nIndex, 2 ] SIZE 150,15 PIXEL OF oDlg ;
ON CHANGE ( cFilter := ResetFilter( aFilters, oDbf, nIndex ), oDlg:Update() )
return oChk
static function ResetFilter( aFilters, oDbf, nIndex )
local cFilter := ""
local af := {}
? "you do whatever you want with nIndex = ", nIndex
AEval( aFilters, { |a| If( a[ 1 ], AAdd( af, a[ 2 ] ), nil ) } )
cFilter := FW_ArrayAsList( af, " .AND. " )
oDbf:SetFilter( cFilter )
oDbf:GoTop()
return cFilter