Page 1 of 1

Datagrids - getting line data from items checked

Posted: Thu Dec 20, 2012 11:53 pm
by cusingerBUSCw5N
I know how to do this the awkward, lengthy way - but I am hoping there is a sleek way:

I want people to be able to check names on a datagrid and then click a button and have the button get the names that were checked and send them to me (in an http tag).

The lengthy way is for each time something is checked, it sends an http tag to update a remote database. But if there is a list of 15 people, that's http messages, which is rather stupid.

Instead, I would like to send one list in one http message

I can't use hilited line - because it's multiple lines... So I need some kind of loop that gets the dgline information, sees if the checked button is hilited, and if so, gives me the name.

So for the first part, if they check the checkbox, I have
if pmousebtnnum is 1 then
if the short name of the target is "check" then
setdataofline the dgline of me, "checked", the hilite of the target
end if
end if

I'm not sure how to loop through the datagrid to get the name

Thanks

Re: Datagrids - getting line data from items checked

Posted: Fri Dec 21, 2012 11:49 am
by Klaus
Hi Carolyn,

do you ever sleep? :D

Where exactly did you put this "mouseup" script?
Directly in the datagrid script or in a "custom behavior" for the datagrid or column?
Is the datagrid of type TABLE or FORM?


Best

Klaus

Re: Datagrids - getting line data from items checked

Posted: Fri Dec 21, 2012 3:06 pm
by cusingerBUSCw5N
About the sleep...Livecode makes me compulsive... In response to your question, it is a form.

OK. I figured out the first part, which is having the checkbox and updating the datagrid The item I am changing is the third item in the data that I am loading. theline is the line that was checked. Here is the code:

Code: Select all

on mouseUp pMouseBtnNum
put the dgHilitedlines of group "DataGrid_meeting" into theline
put the dgdataofline[theline] of group "DataGrid_meeting" into theDataA
##put theDataA["label 3"] into twhat
##answer twhat & " is how we started"
   if the hilite of button "invite" of me is true then
dispatch "SetDataOfLine" to group "datagrid_meeting" of card "outside_features" with theline, "label 3", "true" 
else
   dispatch "SetDataOfLine" to group "datagrid_meeting" of card "outside_features" with theline, "label 3", "false" 
   end if
       put the dgdataofline[theline] of group "DataGrid_meeting" into theDatab
##put theDatab["label 3"] into twhat2
##answer twhat2 & " is how we ended"
end mouseUp
So that works...next step (unless you help me before that...) is to get all the data from the datagrid and send it to me via http

Re: Datagrids - getting line data from items checked

Posted: Fri Dec 21, 2012 3:13 pm
by Klaus
Hm, you answered exactly ONE question of four...

So what info do you need to extract from the datagrid?
theDataA already contains all data from the clicked (?) line of the datagrid!

Re: Datagrids - getting line data from items checked

Posted: Fri Dec 21, 2012 3:18 pm
by cusingerBUSCw5N
Got the rest. Here's how you create the loop:

Code: Select all

put "" into tinvite
   put the dgNumberOfLines of group "datagrid_meeting" into ttotallines
   repeat with i = 1 to ttotallines
      put the dgDataOfLine[i] of group "DataGrid_meeting" into theDataA
      if theDataA["label 3"] is true then
         put tinvite & "^" & theDataA["label 1"]&theDataA["label 2"] into tinvite
         replace space with "" in tinvite
      end if
      end repeat
I put this in: http://mywebsiteusingcoldfusion.cfm?invite="& tinvite & "" and I'm there! :lol:

Re: Datagrids - getting line data from items checked

Posted: Fri Dec 21, 2012 3:21 pm
by Klaus
Aha, great :D

But why are your scripts so horribly (mis)formatted? 8)