Data Grids. Working with buttons and graphics

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Data Grids. Working with buttons and graphics

Post by FireWorx » Mon Mar 05, 2012 5:12 am

Hi,
I am using datagrid helper and have a data grid that is tracking the status of fleet of vehicles. Currently the status column for each vehicle contains either "GREEN", "RED", or "YELLOW". I want to show a green, red, or yellow image in an adjacent column of the same row if the status column for that row is "GREEN" "YELLOW" or "RED" and hide the other images.

I have the ability to extract the data and then via a repeat loop go line by line and check the status column. The tricky part for me is in hiding or showing a button in the adjacent column in the same row. Setting the hilite is also an option

All the buttons int he column are named the same but I assume they can have a different hilite or visibility? Or not the case? How do I refer to "MyButton" in row 1 vs "myButton in row 2?

Anyone?

Thanks,
Dave

Klaus
Posts: 14235
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Data Grids. Working with buttons and graphics

Post by Klaus » Mon Mar 05, 2012 4:19 pm

Hi Dave,

when do you want to do this?
1. When the data get loaded into the datagrid or
2. on user interaction (user clicks a button or whatever)?

1. the best place is the "on fillInData" handler in the behavior script!
2. it depends! :D
Need more info here...


best

Klaus

Klaus
Posts: 14235
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Data Grids. Working with buttons and graphics

Post by Klaus » Mon Mar 05, 2012 4:35 pm

Hi Dave,

for 1 try something like this in the "fillindata" handler of the row behavior.

Attention: Pseudo-Code :D

Code: Select all

on FillInData pDataArray
  put pDataArray["status"] into tStatus
 
  ## Now check what's in tStatus and act accordingly:
  ## or whatever you want to check!
  switch tStatus
    case "GREEN"
       set the hilite of btn "green" of me to true
     break
    case "YELLOW"
      ## do something else
    break
   case "RED"
    ## you get the picture...
  break
  default
    ## if any
  break
 end switch
...
Best

Klaus

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Data Grids. Working with buttons and graphics

Post by FireWorx » Mon Mar 05, 2012 4:56 pm

Thanks very much Klaus,
I will try it later today and re-post.
Dave

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Data Grids. Working with buttons and graphics

Post by FireWorx » Tue Mar 06, 2012 6:03 pm

I had a major headache with data grid helper last night dropping my column atributes. I wasn't able to use your solution Klaus because I couldn't edit the "Row Behavior" unless I switched to "form" from "table" That messed up my table.

What I did do before I had a major headache with having two stacks with the same name open in memory. Boomerang! Was this.

I used the name of the target to identify the name of the button and row. It turns out it is "MyButton 0001" for the button in the first row.
The long name of the target returned button "MyButton 0001" of group "myDatagrid" of group bla of group bla etc.

So once I had that information I was able to check the data in each row and set the image icon of that row by carefully refering to the long name of the button in my repeat loop .

I also now trap for a mouseclick on that button in the datagrid column using the target function and if it exists I alter that row and let the handler in the stack loop through and reset the icons of all the buttons in that column. I had it working pretty good before I had the major boomerang that set me back.

Anyone else have issues with datagrid helper losing column atributes if you copy and paste a datagrids onto a card? I need three identical datagrids and have been crafting one and then copying and pasting to create the other two and renaming them once they are created. Shortly there after the DataGrid helper edit feature comes up blank. Could have been the problem with the other stack open in memory though I guess.

Also deleting a messed up datagrid from the card involves error messages etc and seemingly eratic behavior in datagrid helper. But again at this point could be operator error.

Dave

Post Reply