I got an easy one for you experts out there.....I hope
I have a datagrid in a form format. There are 3 fields per record - title , summary, and link. I added a button that I would like the user to be able to click to launch the website in the link field, but how do I get the field "link" for the record in which the button resides?
Button in a DataGrid Form
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Button in a DataGrid Form
Hi cbarnhart,
I'm no 'expert' but I have worked pretty extensively recently with data grids especially in their 'form' format...
I understand you have 3 fields and a button per record. I understand you want the button click event to jump out to a website link. And I understand that the 'link' is in the 'link' field of the associated record.
IF I'm correct with the above then I would do something like :
(Assuming your 'link' field is called 'fldLink' and your 'link' button is called 'btnLink'
Create a script for the record button in the 'Row Behaviour' script area of the DataGrid :
Think this should help. REMEMBER the 'OF ME' when referrig to any controls in a datagrid...
Regards.
I'm no 'expert' but I have worked pretty extensively recently with data grids especially in their 'form' format...
I understand you have 3 fields and a button per record. I understand you want the button click event to jump out to a website link. And I understand that the 'link' is in the 'link' field of the associated record.
IF I'm correct with the above then I would do something like :
(Assuming your 'link' field is called 'fldLink' and your 'link' button is called 'btnLink'
Create a script for the record button in the 'Row Behaviour' script area of the DataGrid :
Code: Select all
on mouseup pMouseButtonNum
local sTarget, sLink --create the two variables we'll need
put the target into sTarget --This is the name of the button that was clicked
--(ONLY needed if, at some point, you have more than
--one button / record)
if pMouseButtonNum = 1 then --Limit the user to a left mouse click (OPTIONAL)
if "btnLink" is in sTarget then --OR sTarget = "btnLink", as you like
put the text of field "fldLink" [b]of me[/b] into sLink
--here's your link out...
launch url sLink --which should look a little like "http://www.myLinkSite.com/"
end if
end if
end mouse up
Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1
Re: Button in a DataGrid Form
Hi cbarnhart,
here another solution with a script in the button of the template itself and NOT in the behavior:
Best
Klaus
here another solution with a script in the button of the template itself and NOT in the behavior:
Code: Select all
on mouseup
## What is the DATAGRID Index of the clicked row (button)
put the dgindex of me into tCurrentIndex
## get the data for this index:
put the dgDataOfIndex[tCurrentIndex] of grp "your datagrid here..." into tCurrentData
## Now get the URL from this ARRAY
put tCurrentData["url"] into tUrl
## You may want to check if tUrl is empty!
## Now do it:
launch url tUrl
end mouseup
Klaus
Re: Button in a DataGrid Form
Thank you for all the help. I will let you know how it turn out