Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL Lite and QM
#26
Hi Gintaras,
I said I would post the search query addition to dlg_QM_Grid2
This seems to work really well-

Function
Trigger     Help - how to add the trigger to the macro
Code:
Copy      Help
,case 9;; Selct Results of FIND query
,,ARRAY(str) WholeGrid
,,hlv=id(3 hDlg)
,,LvSelect hlv -1;;deselect previously selected items
,,LvGetAll hlv WholeGrid
,,str Query.getwintext((id(11 hDlg)));;a text input box in the dialog
,,str RxSearchTarget
,,int SearchQueryRowMatchesCounter = 0
,,ARRAY(int) SearchQueryRowMatches.create(100);;maximum 100 results
,,int i j
,,for i 0 WholeGrid.len(2) ;;enumerate dimensions  FOR EACH ROW
,,,for j 0 WholeGrid.len(1) ;;enumerate dimension FOR EACH COLUMN
,,,,RxSearchTarget = WholeGrid[j i]
,,,,if(!empty(RxSearchTarget))
,,,,,Query.format("(?i)%s" Query);;makes search query case insensitive
,,,,,if(findrx(RxSearchTarget Query)>-1);; a search hit
,,,,,,SearchQueryRowMatches[SearchQueryRowMatchesCounter] = i;; place the row number of the hit into the cumulative hit array depository
,,,,,,SearchQueryRowMatchesCounter=SearchQueryRowMatchesCounter+1
,,int SearchQueryRowCounter         
,,for SearchQueryRowCounter 0 SearchQueryRowMatches.len    
,,,if SearchQueryRowMatches[SearchQueryRowCounter] > 0
,,,,hlv=id(3 hDlg)
,,,,SetFocus hlv
,,,,LvSelect hlv SearchQueryRowMatches[SearchQueryRowCounter] 1;; don't deselect previous
,,SearchQueryRowMatches=0;;reset
,,WholeGrid=0;;reset

This selects the rows with a match. I am using it on a grid with 15 columns and currently ~50 rows (patients) but I expect there eventually to be 100's (maybe 1000's if I combine many users lists).

I was trying to populate a new qmgrid with the selected results. I know there is a LvGetSelectedItems function but is there a way to populate a qmgrid with the 2 dimentional array easily. I could make a csv first by parsing out the 2dim array and then using ICsv to qmgrid but thought there might be an easier way. If you could just point me in the right direction.
Thanks so much - qmrid + sqlite is awesome....
Stuart


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)