Get line data when the user checks a checkbox (data grid)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
maxvit99
Posts: 5
Joined: Fri Dec 02, 2011 10:08 pm

Get line data when the user checks a checkbox (data grid)

Post by maxvit99 » Wed Jan 16, 2013 6:58 pm

I have a data grid with checkboxes in a column. When the user checks a checkbox i need to get the data of that line and put it into a var to use later (i need to add the price of all the selected attachments and put it into a field). When the user unchecks a checkbox i need to remove the data of that line from the var. This is the code that i have so far in the data grid's script:

Code: Select all

on mouseUp pMouseBtnNum
   if pMouseBtnNum is 1 then
      if the short name of the target is "Check" then
         if the hilite of button "Check" is true then
            answer "checked"
         else
            answer "unchecked"
         end if
      end if
   end if
end mouseUp
(the 2 answers are to see what happens)
This code works correctly only for the first row in the data grid. If i check/uncheck another row it always answers "checked".
Also the dgDataOfLine, dgDataOfIndex, GetDataOfIndex and GetDataOfLine are empty so i don't have a way to get a lines data.

Could anyone please help me to do this?

Thanks,
Max

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Get line data when the user checks a checkbox (data grid

Post by Klaus » Wed Jan 16, 2013 10:41 pm

Hi Max,

is the datagrid a FORM or a TABLE?
If FORM, does it have a custom behavior?
If yes, did you already script what you want into the behavior?
If not, you should 8)

What did you try with "dgDataOfLine, dgDataOfIndex, GetDataOfIndex, GetDataOfLine"?
That's the way to go, but maybe in another script?

It looks like you put your "mouseup" handler directly into the group script, right?
In that case this does happen:
1. you click the button of line 1 -> hilite of btn "Check" -> TRUE
2. Since Datagrids are a LOT of objects grouped together, you will have MORE than one button named "Check" on your card,
so asking "the hilite of btn Check" will only return the hilite of the FIRST button (lowest layer) named "Check"!
Uncheck that first button and you will always get "unchecked"!

As always, datagrids ARE complex beasts :D


Best

Klaus

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Get line data when the user checks a checkbox (data grid

Post by keram » Thu Jan 30, 2014 10:30 am

Hi Max,

Have you got it working properly?
I have a very similar problem to solve so if you got it right then please post the solution.

Thanks!

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Get line data when the user checks a checkbox (data grid

Post by Klaus » Thu Jan 30, 2014 6:49 pm

Hi Keram,

better open a new thread for your problem, no idea if and when the OP will ever answer. 8)


Best

Klaus

Post Reply