Getting Data Grid values - what I am doing wrong?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
uimike
Posts: 2
Joined: Thu Oct 15, 2009 1:23 am

Getting Data Grid values - what I am doing wrong?

Post by uimike » Thu Oct 15, 2009 1:39 am

Any help appreciated...

I have a series of buttons, each with a mouseEnter handler. When the mouse enters a button, a field is shown near it. In that field, I want to put a value. That value is in column 2 of a data grid. In column 1 is the name of the button.

So what I _thought_ I needed to do is:

- Put the short name of the button in a global variable, then
- somewhere, create a script that tried to match that value to one of the values in column 1.
- if it matched, it would get the value in column 2, put it in a global variable, and put that into the field beside the button.

I realize (after reading posts here) that the script for getting the values of the columns had to be _inside_ the data grid group.

But now I don't know how to, from outside of that grid, trigger that script and get the value I want. I tried adding a button inside the grid group, and issuing a "click button of group..." - but that was a disaster...

Any ideas? much thanks!

mike

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Thu Oct 15, 2009 2:07 am

I think you can use FindIndex combined with defining your own custom proeprty to accomplish what you are after.

Data Grid API

Try adding something like this to your Data Grid Group script (untested and needs you to fill in correct column names):

Code: Select all

getprop uButtonValue [ pButtonName ]
    FindIndex NAME_OF_COL_WITH_BUTTON_NAME, pButtonName
    put the result into theIndex
    if theIndex > 0 then
        return GetDataOfIndex( theIndex, NAME_OF_COL_WITH_VALUE) 
    else
        return empty
    end if
end uButtonValue
Once you place this code in your Data Grid group script you can access the value for a button like this:

Code: Select all

put the uButtonValue[ BUTTON_NAME ] of group "DataGrid" into theValue
Make sense?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

uimike
Posts: 2
Joined: Thu Oct 15, 2009 1:23 am

Post by uimike » Fri Oct 16, 2009 12:35 am

Trevor,

Awesome - that did the trick, exactly what I needed! Many thanks!

And opens up a whole lot of possibilities for me :)

mike c

Post Reply