Getting data from 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
snappy
Posts: 19
Joined: Tue Oct 08, 2013 10:02 am

Getting data from a Data Grid

Post by snappy » Thu Mar 20, 2014 11:10 am

Hi,

I've done several hours of searching but I can't seem to solve this problem:

I want to get data from a field in a Data Grid and pass it into a text field on another card in another stack.

I can't seem to figure out how to do that. Any ideas?

I should also say that I'm using the Data Grid as a resource only. The user never interacts with it.

Thanks,
snappy

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Getting data from a Data Grid

Post by MaxV » Thu Mar 20, 2014 11:45 am

Use the dgData property, it's just an arrya:
dgData
Usage:

Code: Select all

get the dgData
set the dgData of group "DataGrid" to pDataArray
Get or set the data array that the data grid will display. The array organization is the following: dgData[row][column_name], where row is an integer and column_name is a string. The first dimension of the array uses numeric keys and the value of each is an array. You can store anything you would like in each numeric key's array. For data grid tables the keys should match the column names in order for the data grid to correctly map the array value to the column cell. The following array would represent two records in the data grid:

Code: Select all

put "Hi" into theA[1]["message"]
put "Bye" into theA[2]["message"]
set the dgData of group "DataGrid" to theA
:wink:
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Getting data from a Data Grid

Post by dunbarx » Thu Mar 20, 2014 1:27 pm

What MaxV said.

Note that you can also extract data in the clear by using the "dgText" property. This gives a tab and return delimited data set.

You have to start using the DataGrid manual. This can be found here:

http://lessons.runrev.com/m/datagrid

Craig Newman

snappy
Posts: 19
Joined: Tue Oct 08, 2013 10:02 am

Re: Getting data from a Data Grid

Post by snappy » Fri Mar 21, 2014 8:15 am

Thanks, guys.

I clearly need to learn more. I'm not sure how to apply your information. I started on LiveCode last year but let my knowledge lapse.

I'm still trying to learn the basics. Might be getting ahead of myself, here.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Getting data from a Data Grid

Post by MaxV » Fri Mar 21, 2014 10:14 am

For example you have a datagrid called "mytable", this datagrid has 2 columns named "myFirstCol" and "mySecondCol". If you want to know the value of the cell in the second row and second column you just type:

Code: Select all

put the dgData of group "mytable" into temp
put temp[2]["mySecondCol"]
See also http://livecode.wikia.com/wiki/Arrays
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply