Page 1 of 2
combosearchgrid with sqlite
Posted: Sun Nov 27, 2016 4:59 pm
by giampy
Ciao a tutti,
I like combosearchgrid and I would use it with sqlite to do research on a table of cities. For table limit the number of records would use in the property "onchange" the query "
Code: Select all
aTable: = sql (dbo," select * from cap where localita like "+ cRic + "Limit 10")
The problem is that it lacks onchange in combosearchgrid properties.
Can fix it ?
Thank you all, ciao
Giampy
Re: combosearchgrid with sqlite
Posted: Sun Nov 27, 2016 5:30 pm
by serge_girard
Hello Giampy, welcome from Belgica !
I don't know 'combosearchgrid' but I'm sure somebody knows all about it and will help you !
Serge
Re: combosearchgrid with sqlite
Posted: Sun Nov 27, 2016 5:44 pm
by giampy
Hello Serge,
Thank you for answer.
Combosearchgrid is a beautiful control that helps in record queries.
Found in "Minigui/Samples/Advanced" and also in the forum.
Ciao, Giampy
Re: combosearchgrid with sqlite
Posted: Sun Nov 27, 2016 5:54 pm
by Rathinagiri
Hi,
ComboSearchGrid itself is based on the OnChange event of the textbox.
However you can dig in the code and change the way you want.
Combosearchgrid with sqlite
Posted: Sun Nov 27, 2016 6:15 pm
by Pablo CĂ©sar
Ciao Giampy, benvenuto alla nostra comunitĂ !
Rathinagiri wrote:However you can dig in the code and change the way you want.
And please, share with us all your improvements in it...
Re: combosearchgrid with sqlite
Posted: Sun Nov 27, 2016 8:15 pm
by giampy
Ciao a tutti,
thanks for the welcome and the answer.
The OnChange event is for internal use only and not for the user.
Also it is very difficult to change the internal code and I am not able to change it.
I tried to edit comboserarchgrid.prg but does not work.
Ciao, Giampy
Re: combosearchgrid with sqlite
Posted: Mon Nov 28, 2016 4:35 am
by Rathinagiri
Hi,
Now I have added a new property called QueryLimit and please see the demo.
Re: combosearchgrid with sqlite
Posted: Mon Nov 28, 2016 7:42 am
by dragancesu
Hello Rathi,
I tried the program works as it is written, but I think the search should have been done a little differently
Now works as a smartphone, search phrase anywhere and it confuses
Added the % character at the beginning and end of the phrase that I would not do that, it should users to enter, starting the phrase should be % so how is still entered
In the case of the random keys are now and what they are realistic, for example, the cities?
Re: combosearchgrid with sqlite
Posted: Mon Nov 28, 2016 10:15 am
by Rathinagiri
If you want only search using the starting characters, try
anywheresearch .f.
Re: combosearchgrid with sqlite
Posted: Mon Nov 28, 2016 1:11 pm
by serge_girard
Hello Giampy,
Maybe this code can help you:
It allows 3 "filter-fields" and when you type something in it the Load_DBF is called and the selected records are filtered by the EvalFilter() function.
Code: Select all
aKL_NM := {} // dummy
DEFINE WINDOW Form_KLANTEN ;
...
@ 10,10 TEXTBOX F_NAAM ;
WIDTH 200 ;
VALUE '' ;
TOOLTIP 'Naam' ;
MAXLENGTH 30 ;
FONT 'Arial' SIZE 09 ;
BACKCOLOR SILVER ;
FONTCOLOR BLUE BOLD ;
ON GOTFOCUS Form_KLANTEN.F_NAAM.BackColor := WHITE ;
ON LOSTFOCUS Form_KLANTEN.F_NAAM.BackColor := SILVER ;
ON CHANGE Load_DBF()
@ 10,215 TEXTBOX F_STRAAT ;
WIDTH 150 ;
VALUE '' ;
TOOLTIP 'Straatnaam' ;
MAXLENGTH 30 ;
FONT 'Arial' SIZE 09 ;
BACKCOLOR SILVER ;
FONTCOLOR BLUE BOLD ;
ON GOTFOCUS Form_KLANTEN.F_STRAAT.BackColor := WHITE ;
ON LOSTFOCUS Form_KLANTEN.F_STRAAT.BackColor := SILVER ;
ON CHANGE Load_DBF()
@ 10,382 TEXTBOX F_GEM ;
WIDTH 170 ;
VALUE '' ;
TOOLTIP 'Woonplaats' ;
MAXLENGTH 30 ;
FONT 'Arial' SIZE 09 ;
BACKCOLOR SILVER ;
FONTCOLOR BLUE BOLD ;
ON GOTFOCUS Form_KLANTEN.F_GEM.BackColor := WHITE ;
ON LOSTFOCUS Form_KLANTEN.F_GEM.BackColor := SILVER ;
ON CHANGE Load_DBF()
DEFINE GRID GRID_KL_NM
ROW 40
COL 10
WIDTH 570
HEIGHT 265
HEADERS {"Kl" , "Naam", 'Straat','Huisnr', 'Woonplaats','BTW', 'Email'}
WIDTHS { 1, 200, 150, 20, 180 , 50 , 50 }
JUSTIFY {GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT, GRID_JTFY_LEFT , GRID_JTFY_LEFT }
ON DBLCLICK Edit_klant()
ITEMS aKL_NM
END GRID
...
END WINDOW
function Load_DBF()
/******************/
fNAAM := UPPER(ALLTRIM(GetProperty ( 'Form_KLANTEN' , 'F_NAAM' , 'Value' )))
fSTRAAT := UPPER(ALLTRIM(GetProperty ( 'Form_KLANTEN' , 'F_STRAAT' , 'Value' )))
fGEM := UPPER(ALLTRIM(GetProperty ( 'Form_KLANTEN' , 'F_GEM' , 'Value' )))
aFILTER := {}
IF !EMPTY(fNAAM)
AADD(aFILTER, {|| fNAAM $ UPPER(ALLTRIM(NAAM)) })
ENDIF
IF !EMPTY(fSTRAAT)
AADD(aFILTER, {|| fSTRAAT $ UPPER(ALLTRIM(STRAAT)) })
ENDIF
IF !EMPTY(fGEM)
AADD(aFILTER, {|| fGEM $ UPPER(ALLTRIM(WOONPLAATS)) })
ENDIF
USE ..DBF
GO TOP
DELETE ITEM ALL FROM GRID_KL_NM OF Form_KLANTEN
DO WHILE .NOT. EOF()
IF EvalFilter()
ADD ITEM { PADL(ALLTRIM(STR(KL_NR)), 8, '0') , ALLTRIM(NAAM), ALLTRIM(STRAAT), ALLTRIM(HUISNR) ,ALLTRIM(WOONPLAATS), BTW_NR, EMAILADRES } TO GRID_KL_NM OF Form_KLANTEN
ENDIF
SKIP
ENDDO
CLOSE KLANTEN
RETURN
FUNCTION EvalFilter()
****************************
LOCAL lRETVAL := TRUE
LOCAL i
FOR i := 1 TO LEN(aFILTER)
lRETVAL := lRETVAL .AND. EVAL(aFILTER [i])
NEXT
RETURN lRETVAL
Serge