Display specific cells from a data grid or table

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jakea782
Posts: 26
Joined: Wed Dec 11, 2013 4:43 pm

Display specific cells from a data grid or table

Post by jakea782 » Wed Dec 11, 2013 4:48 pm

I'm building an education game that switches words on different levels and I need a way to display the words that are in a data grid. I couldn't really find the exact command that allows you to display a cell. Anyone have a solution?

Klaus
Posts: 13871
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display specific cells from a data grid or table

Post by Klaus » Wed Dec 11, 2013 4:54 pm

Hi jakea,

1. welcome to the forum! :D

2. we need MORE info about what you are trying to do! 8)
When do you want to display? "on mouseup" or something?
Is the appropriate row in your datagrid already hilighted?


Best

Klaus

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am
Location: Warszawa / Poland

Re: Display specific cells from a data grid or table

Post by snm » Wed Dec 11, 2013 6:46 pm

Check dgDataOfLine or dgDataOfIndex. It gives you array with indexes=names of columns and values of cells from hilited line. You can even use array with all DataGrid content:

Code: Select all

put the dgData of grp "yourDataGridName" into theArray
First index of the array is rów number and second is column name.

Marek

jakea782
Posts: 26
Joined: Wed Dec 11, 2013 4:43 pm

Re: Display specific cells from a data grid or table

Post by jakea782 » Wed Dec 11, 2013 11:45 pm

Sorry, as you can tell still a noob. What i'm doing exactly is when I push on a button, I want it to display a specific word as it goes down the screen. I figured it would be some array. As the game progresses, I want the word to change as it comes down in the next iteration. I figured out the switching part (I believe) but I couldn't figure out the displaying aspect of it. In the code below:

put the dgData of grp "yourDataGridName" into theArray

The suggestion was "First index of the array is rów number and second is column name". Is the syntax just "into (1,1)"?

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am
Location: Warszawa / Poland

Re: Display specific cells from a data grid or table

Post by snm » Thu Dec 12, 2013 8:14 am

Syntax is as in example code "into theArray".
Then you can get value from any element of the Array as theArray[row nr][column name].

Marek

jakea782
Posts: 26
Joined: Wed Dec 11, 2013 4:43 pm

Re: Display specific cells from a data grid or table

Post by jakea782 » Thu Dec 12, 2013 11:27 am

How does the data go into the button?

Klaus
Posts: 13871
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display specific cells from a data grid or table

Post by Klaus » Thu Dec 12, 2013 1:56 pm

Again my questions:
When do you want to display? "on mouseup" or something?
Where and what do you want to display?
Is the appropriate row in your datagrid already hilighted?
Noob or not, you should be able to explain your problem COMPLETELY
in a way we can understand it and help you!

Right now we get a tiny piece of info every day 8)

jakea782
Posts: 26
Joined: Wed Dec 11, 2013 4:43 pm

Re: Display specific cells from a data grid or table

Post by jakea782 » Thu Dec 12, 2013 2:51 pm

Yes, I want the text to be displayed on "Button1" after I press (on mouseUp) "Button2". Maybe I have to use a field to display the text instead but I'm not sure about that. What I want to display is a just that contents that is in a specific cell such as "Talk". So I want "Talk" to be displayed in "Button1" after I push "Button2" but I want to be able to change the text displayed if I push a different button.

Push Button2 = Button1 Displays Row 1, Column 1
Push Button3 = Button1 Displays Row 1, Column 2
Push Button4 = Button1 Displays Row 1, Column 3

I don't want to simply just insert text into the button. I want it to insert the contents of the cells in the button or field as part of the gameplay depends on a multitude of columns and rows from the data grid. No the row is not highlighted. Would I need to do that first?

Appreciate all the help guys or girls!

Klaus
Posts: 13871
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display specific cells from a data grid or table

Post by Klaus » Thu Dec 12, 2013 3:02 pm

Hi jakea782,

AHA, we are getting nearer :D

OK, I am sure you gave the columns a NAME, right?
Or are they still named "Column 1" etc?

Whatever, you need to do this:

Code: Select all

on mouseup
  ## Get the data of the desired line -> 1 in this example, and NOT the complete dgdata:
  put the dgDataOfLine[1] of grp "Your datagrid here..." into tData
  
  ## Now get the value of the column:
  put tData["name of your column 1 here..."] into tDesiredValue
  
  ## Now you can put tDesiredValue into a field or whatever...
end mouseup
You get the picture :D

Best

Klaus

jakea782
Posts: 26
Joined: Wed Dec 11, 2013 4:43 pm

Re: Display specific cells from a data grid or table

Post by jakea782 » Thu Dec 12, 2013 4:07 pm

AWESOME! Works great now. As a neighbor just in Switzerland I say Danke! You too as well snm. :D

Klaus
Posts: 13871
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display specific cells from a data grid or table

Post by Klaus » Thu Dec 12, 2013 4:23 pm

Alles durch "Chrüterchraft"! :D

ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

Re: Display specific cells from a data grid or table

Post by ronbird » Tue Sep 16, 2014 12:05 am

Hi guys, I plan a card with a multi row/column grid or table.
The cells will contain all the text necessary through out the stack.
When a card loads, it will look at the grid/table card and request the appropriate text to populate the fields and buttons on that card.
That way I can maintain the text in one place and not have to update each card.
But....I'm having difficulty writing the script. For eample -put line 2 of field"tableField"- reads all the cells not just the first cell.
And I just cant seem to get my head arround DataGrids.
All help would be greatly appreciated, Ron

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

Re: Display specific cells from a data grid or table

Post by bangkok » Tue Sep 16, 2014 9:28 am

And I just cant seem to get my head arround DataGrids.
The best way to learn is to... look.

http://forums.livecode.com/viewtopic.ph ... 40#p108733

Klaus
Posts: 13871
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display specific cells from a data grid or table

Post by Klaus » Tue Sep 16, 2014 12:34 pm

Hi Ron,

1. please open a new thread and do not try to revive an old and dead one!
A couple of month = OLD :D
2. Please open the thread in the correct forum, your question does not show any context to GAMES 8)
Sounds more like a beginners question.


Best

Klaus

Post Reply

Return to “Games”