Data Grid Multiple Select Query

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Phil_p
Posts: 7
Joined: Wed Sep 07, 2011 10:28 pm

Data Grid Multiple Select Query

Post by Phil_p » Sat Sep 10, 2011 2:59 pm

Hi

I would like to know how I can use a variable instead of the ctrl key to select multiple rows. At the moment you need to ctrl click on the rows but I would like to have a variable which is set to true or false, when true it will be as if you have ctrl clicked on a row.

Hope this makes sense

regards

Phil

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Data Grid Multiple Select Query

Post by sturgis » Sat Sep 10, 2011 4:16 pm

If you are using a datagrid form, something like the following should work in the row behavior script.

Code: Select all

on mouseDown
   if the mycheckprop of this stack is true then -- check flag property
      set the wholematches to true -- to avoid accidental matches
      put the dgHilitedLines of me into tLines -- grab currently hilited
      put itemoffset(the dgLine of me,tLines) into tMatch -- see if line is already hilited
      if tMatch > 0 then -- if line is already hilited, remove it from the list
         delete item tMatch in tLines
         set the dgHilitedLInes of me to tLines -- set updated hilite list
      else -- if line isn't already hilited
         put the number of items in tLines + 1 into tNum
         put the dgLine of me into item tNum of tLines -- add it to the list of items in tLines
         sort items of tLines ascending numeric -- sort em. Don't know if this matters or not
         set the dghilitedlines of me to tLines -- set to the updated hilite list
      end if
   else -- if our property is false, just pass mouseDown
      pass mouseDown
   end if
end mouseDown
To toggle it with code:

Code: Select all

set the mycheckprop of this stack to true -- turns it on
set the mycheckprop of this stack to false -- turns it off
It would be a bit more complex (maybe?) when dealing with a table rather than a form, but the idea should be similar.

Phil_p
Posts: 7
Joined: Wed Sep 07, 2011 10:28 pm

Re: Data Grid Multiple Select Query

Post by Phil_p » Sat Sep 10, 2011 6:30 pm

I was along the right lines with this but that looks like it will work a treat.

Many thanks

Post Reply