Getting selected text of a 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
Jayare
Posts: 12
Joined: Sat Apr 28, 2012 1:34 pm

Getting selected text of a Data Grid

Post by Jayare » Tue Jun 26, 2012 8:49 pm

Hello everybody,

i have created a simple Data Grid with two Colums. There are several lines of text in the Data Grid. My user should select one of the shown Rows. I want to get the data of a selected row in a variable.

I have done this in a scrolling field with this code (here it is simple!):
"put the selectedtext of field "artikelportal" into gAnzeige_artikel"

It would be great, if anybody could tell me, how i can do this action in a Data Grid!!!!

thanks
Jochen

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Getting selected text of a Data Grid

Post by townsend » Tue Jun 26, 2012 9:20 pm

I think you'll find the answer you're looking for here:
Create, Read, Update, Delete Example

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

Re: Getting selected text of a Data Grid

Post by sturgis » Tue Jun 26, 2012 9:33 pm

Jochen, check out the lesson here for the datagrid: http://lessons.runrev.com/s/lessons/m/d ... -or-column

I think this will get you pointed the right direction.
Jayare wrote:Hello everybody,

i have created a simple Data Grid with two Colums. There are several lines of text in the Data Grid. My user should select one of the shown Rows. I want to get the data of a selected row in a variable.

I have done this in a scrolling field with this code (here it is simple!):
"put the selectedtext of field "artikelportal" into gAnzeige_artikel"

It would be great, if anybody could tell me, how i can do this action in a Data Grid!!!!

thanks
Jochen

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Getting selected text of a Data Grid

Post by townsend » Tue Jun 26, 2012 10:04 pm

I found this in the doUpdate handler. I think that's what you're looking for.

Code: Select all

     put the dgHilitedLines of group "mygrid" into theLine  --grabs hilited line
     put the dgDataOfLine[theLine] of group "mygrid" into theDataA
     -- theDataA is now an array variable.
     -- then you get the specific column values by using the column names
     put theDataA["Handle"] into myHandle 
     put theDataA["Entry"] into myEntry 

Jayare
Posts: 12
Joined: Sat Apr 28, 2012 1:34 pm

Re: Getting selected text of a Data Grid

Post by Jayare » Sun Jul 01, 2012 10:27 am

WOW, you guys Rock!!!!

Now everything works perfect.

Thanks
Jochen

Post Reply