combosearchgrid with sqlite

Moderator: Rathinagiri

giampy
Posts: 4
Joined: Sun Oct 30, 2016 5:35 pm
Location: Marcon, Venice

combosearchgrid with sqlite

Post by giampy » Sun Nov 27, 2016 4:59 pm

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

User avatar
serge_girard
Posts: 2348
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 590 times
Been thanked: 124 times
Contact:

Post by serge_girard » Sun Nov 27, 2016 5:30 pm

Hello Giampy, welcome from Belgica !

I don't know 'combosearchgrid' but I'm sure somebody knows all about it and will help you !

Serge

giampy
Posts: 4
Joined: Sun Oct 30, 2016 5:35 pm
Location: Marcon, Venice

Post by giampy » Sun Nov 27, 2016 5:44 pm

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

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Sun Nov 27, 2016 5:54 pm

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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Sun Nov 27, 2016 6:15 pm

Ciao Giampy, benvenuto alla nostra comunità ! :D
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... ;)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

giampy
Posts: 4
Joined: Sun Oct 30, 2016 5:35 pm
Location: Marcon, Venice

Post by giampy » Sun Nov 27, 2016 8:15 pm

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

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Mon Nov 28, 2016 4:35 am

Hi,

Now I have added a new property called QueryLimit and please see the demo.
combosearchgrid.zip
(7.4 KiB) Downloaded 155 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
dragancesu
Posts: 700
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 23 times
Been thanked: 149 times

Post by dragancesu » Mon Nov 28, 2016 7:42 am

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?

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Mon Nov 28, 2016 10:15 am

If you want only search using the starting characters, try

anywheresearch .f.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
serge_girard
Posts: 2348
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 590 times
Been thanked: 124 times
Contact:

Post by serge_girard » Mon Nov 28, 2016 1:11 pm

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

Post Reply