Page 1 of 1

Data grid displaying an array of items?

Posted: Sun Jan 31, 2016 5:45 pm
by hairydalek
Hi,
next on my list of things to do is to present a set of options nicely. Currently I’m using a data grid. At the moment, the data is hard coded as I want to get it working, but the aim is to have the data grid populated by looking in a folder of files and presenting those as a list of options. The plan will be to have the user create templates, which will be stored in the user’s folder somewhere, and those will be shown by reading them from disk and displaying them in some kind of tabular form. Right now, though, I’m just looking at techniques and how to achieve what I want.

So, I have a substack that is displayed in a new window (eventually a sheet of modular window) which displays a data grid. Each row is currently an item, so what I am getting is a long scrollable list of items (in this case, options for a background texture - all displayed images are 200x100 pixels). Each is clickable and when clicked on, changes the background texture of the image being worked on, and the sub stack is closed. This seems OK for, say, one or two items, but anything more and you start to get a ling column if items.

Let’s say I have 9 items to display. Right now, I’d have 9 row high column, which is silly (imagine if it were 20 high). What I want is a 3x3 table. Each element will be clickable and will trigger a change in the main stack window.

Right now, I’m using a data grid as a form. As I understand it, if I use a table, it’s each row that is clickable and will return a value, not each cell. Is that correct, or will each cell return a unique identifier when clicked which I can use to interpret the desired choice? Or is there a way of setting the button in the layout template to return the value I need?

Or should I programatically create a whole load of buttons (which would need to be in a scrollable group) when the main stack is loaded?

I’ve been trying to find answers, but haven’t come up with anything in the documentation or on line lessons that seem to help this time (usually, answers have been fairly easy to find and follow),and Google seems to offer little extra to add to my thoughts. Obviously trying to think of the most sensible and manageable way to do what I want.

Re: Data grid displaying an array of items?

Posted: Sun Jan 31, 2016 7:28 pm
by sritcp
hairydalek wrote:As I understand it, if I use a table, it’s each row that is clickable and will return a value, not each cell. Is that correct, or will each cell return a unique identifier when clicked which I can use to interpret the desired choice?
It will identify each cell -- more correctly, the object inside the cell that was clicked on.
For instance, if you place the following code in the DG's script :

Code: Select all

on mouseUp
   put the  name of the target into msg
end mouseUp
it will return the name of the object in the cell that was clicked on (e.g., field "myField", image "texture22", etc.).
You can also employ dgIndex, dgColumn, etc. to extract additional information. See Datagrid documentation.

Regards,
Sri

Re: Data grid displaying an array of items?

Posted: Sun Jan 31, 2016 9:20 pm
by hairydalek
Thanks, Sri. I'll have an experiment with that. It sounds like your suggestion will get me to where I want to be.

Re: Data grid displaying an array of items?

Posted: Mon Feb 01, 2016 1:41 pm
by Klaus
Find the datagrids docs as PDF here: http://lessons.livecode.com/m/datagrid