Display specific cells from a data grid or table
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Display specific cells from a data grid or table
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?
Re: Display specific cells from a data grid or table
Hi jakea,
1. welcome to the forum!
2. we need MORE info about what you are trying to do!
When do you want to display? "on mouseup" or something?
Is the appropriate row in your datagrid already hilighted?
Best
Klaus
1. welcome to the forum!
2. we need MORE info about what you are trying to do!
When do you want to display? "on mouseup" or something?
Is the appropriate row in your datagrid already hilighted?
Best
Klaus
-
- 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
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:
First index of the array is rów number and second is column name.
Marek
Code: Select all
put the dgData of grp "yourDataGridName" into theArray
Marek
Re: Display specific cells from a data grid or table
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)"?
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)"?
-
- 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
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
Then you can get value from any element of the Array as theArray[row nr][column name].
Marek
Re: Display specific cells from a data grid or table
How does the data go into the button?
Re: Display specific cells from a data grid or table
Again my questions:
in a way we can understand it and help you!
Right now we get a tiny piece of info every day
Noob or not, you should be able to explain your problem COMPLETELYWhen 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?
in a way we can understand it and help you!
Right now we get a tiny piece of info every day
Re: Display specific cells from a data grid or table
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!
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!
Re: Display specific cells from a data grid or table
Hi jakea782,
AHA, we are getting nearer
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:
You get the picture
Best
Klaus
AHA, we are getting nearer
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
Best
Klaus
Re: Display specific cells from a data grid or table
AWESOME! Works great now. As a neighbor just in Switzerland I say Danke! You too as well snm.
Re: Display specific cells from a data grid or table
Alles durch "Chrüterchraft"!
Re: Display specific cells from a data grid or table
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
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
Re: Display specific cells from a data grid or table
The best way to learn is to... look.And I just cant seem to get my head arround DataGrids.
http://forums.livecode.com/viewtopic.ph ... 40#p108733
Re: Display specific cells from a data grid or table
Hi Ron,
1. please open a new thread and do not try to revive an old and dead one!
A couple of month = OLD
2. Please open the thread in the correct forum, your question does not show any context to GAMES
Sounds more like a beginners question.
Best
Klaus
1. please open a new thread and do not try to revive an old and dead one!
A couple of month = OLD
2. Please open the thread in the correct forum, your question does not show any context to GAMES
Sounds more like a beginners question.
Best
Klaus