Selecting a row of data in 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
melhiatt
Posts: 68
Joined: Wed May 25, 2011 9:17 am

Selecting a row of data in a data grid

Post by melhiatt » Tue Aug 23, 2011 5:31 am

I have an app with my data in a datagrid. I want to be able to click on a record in the datagrid and have the app take me to a new "screen" (card) and have the information from the selected record appear in individual fields (just like in your phone contacts, when you tap on a record it takes you to a new screen that displays that record). Please point me in the right direction to be able to do this. Thanks!

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Selecting a row of data in a data grid

Post by BarrySumpter » Tue Aug 23, 2011 5:44 am

Make sure you understand LiveCode Arrays first.
Don't take anything you've leaned in another language for granted.
LiveCode does everything differently.

the best resource for the datagrid:
LiveCode Data Grid
http://lessons.runrev.com/spaces/lesson ... s/datagrid
The pdf on the right has more examples and more complex themes.

More specificly:
Send variable from one card to another card?
http://forums.runrev.com/viewtopic.php?f=7&t=7772

Fourth World Scripting Syle Guide:
http://www.fourthworld.com/embassy/arti ... style.html


Code: Select all

...
     --  GLOBALS MUST be declared in EVERY routine you want to use them in 
     --  GLOBLAS they WILL retain their value
     --          Although globals are not the recommended way to pass info from one card to another
     - -                its easier to understand here to get started

     GLOBAL gNumberOfCats
     GLOBAL gNumberofDogs
     GLOBAL gNumberofMice

      put the dgHilitedLine of group "dgMyDataGrid" into theLine   
                -- theLine - this is just a number i.e. 1 or 5 etc
      
      put the dgDataOfLine[theLine] of group "dgMyDataGrid" into theDataA    
              --  theDataA - this is just a single occurance array - with column names as the index

      put theDataA["Cats"] into gNumberOfCats
      put theDataA["Dogs"] into gNumberofDogs
      put theDataA["Mice"] into gNumberofMice

      go to card crdEditMyPets
      -- crdEditMyPets - this is just another card to edit the values of these globals
...

hth
Last edited by BarrySumpter on Wed Aug 24, 2011 2:24 am, edited 7 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Selecting a row of data in a data grid

Post by bangkok » Tue Aug 23, 2011 6:18 am

melhiatt wrote:I have an app with my data in a datagrid. I want to be able to click on a record in the datagrid
http://forums.runrev.com/viewtopic.php?f=7&t=7865

A small stack with DG examples with a way to handle mouseup on a datagrid, and know which line and column.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Selecting a row of data in a data grid

Post by BarrySumpter » Tue Aug 23, 2011 7:24 am

Hey bangkok,

Always wanted to ask
is there a way to trieve the column number and the row number and the cell value?

Then be able to use a routine to udpate the cell value using the row and column number
without reloading the table?

Then the next question would be
how to simple retrieve the data from cell Column, Row. etc.

What is search mode.

And I can see 2 save to file methods but not a retrieve from file method.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

melhiatt
Posts: 68
Joined: Wed May 25, 2011 9:17 am

Re: Selecting a row of data in a data grid

Post by melhiatt » Wed Aug 24, 2011 1:17 am

I'm sorry to be such an uninformed newbie. Sometimes in the code that people post I have a hard time determining what are object names that people have created and what are predefined commands or words of code in LiveCode. My datagrid is named "MyDG", the card that it is on is "data", the card that I want the information from the hilighted record to feed to is called "record". I have several fields created on the card "record", ie. "first name", "last name", etc. that I want the data to appear in.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Selecting a row of data in a data grid

Post by BarrySumpter » Wed Aug 24, 2011 2:07 am

I've changed my code list above to be easier to read.

You'll need to go ahead and take the time to read thru more of the instructions I've listed in the hyperlinks above.

I'm there now creating my first edit card based on data from a datagrid on another card.

LiveCode is NOT easy to learn.
Especially if you've come from any type of coding language.

I did NOT find an example of Editing a line/row of data
from a datagrid that is located on another card
like you were asking for.

The datagrid is NOT in the LiveCode dictionary.
Its easier to find datagrid related topics using Google and searching with:
LiveCode DataGrid MySearchWords

i.e. Run a Google search on:
LiveCode DataGrid dgHilitedLine
and
LiveCode DataGrid dgDataOfLine

That Google seach will not only return the LiveCode DataGrid Properties webpage link
but also links to LiveCode Forum posts.
Last edited by BarrySumpter on Wed Aug 24, 2011 7:41 am, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

melhiatt
Posts: 68
Joined: Wed May 25, 2011 9:17 am

Re: Selecting a row of data in a data grid

Post by melhiatt » Wed Aug 24, 2011 5:01 am

Thanks, I've been reading all evening and I'll see what I can do. I'm not coming from a previous language, just an end user. I did the summer academy, but that only scratched the surface and I'm finding it's hard to fill in all the holes. Thanks for your time!

Post Reply