Change datagrid backgroundcolor for a row from code [SOLVED]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Nicke
Posts: 36
Joined: Thu Nov 28, 2013 11:19 am
Location: Helsinki, Finland

Re: Change datagrid backgroundcolor for a row from code

Post by Nicke » Sat May 10, 2014 9:56 am

Hi,

the reset also resets the active hilite so that is not an option. I tried with the lighter green background color but at least on a linux machine there is no different (look at the screenshot)

Image

I have to investigate the background color opacity but besides that you have solved my problem, thank you Simon!

BR
Nicke

Nicke
Posts: 36
Joined: Thu Nov 28, 2013 11:19 am
Location: Helsinki, Finland

Re: Change datagrid backgroundcolor for a row from code

Post by Nicke » Thu May 15, 2014 11:04 am

Ok, I'm back to square one. The code I thought was working is not working as I need.

Code: Select all

on mouseUp
   repeat with x = 1 to 4
      set the opaque of field ("Col" && x &&  "0002") of grp "DG1" to true
      set the backgroundColor of field ("Col" && x &&  "0002") of grp "DG1" to "green"
   end repeat
end mouseUp
This will change the background color on row 2 but when I scroll down the "next" line 2 that is outside the area I can see it is also green. So "0002" seems to be tied to the "view area" not the actual line of the datagrid. Using backgroundcolor with opaque also makes the "hilite bar" of the selected line to be under the background color (see post above).

So I would like to have the background of one chosen datagrid line to be colored in the same way as "Alternate Row Colors" works and still be able to use the datagrid as normally.

Is this possible at all?

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Change datagrid backgroundcolor for a row from code

Post by keram » Thu May 15, 2014 11:51 am

Hi Nicke,
Nicke wrote:So "0002" seems to be tied to the "view area" not the actual line of the datagrid.
I had a similar problem with a DG I'm working on and solved it by adding a fixed number to each row in the data before I populated the DG. Then that number I used as a reference in various views I wanted to select from the DG.
I'm not completely sure how you are getting your DG populated but you could try the above.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Nicke
Posts: 36
Joined: Thu Nov 28, 2013 11:19 am
Location: Helsinki, Finland

Re: Change datagrid backgroundcolor for a row from code

Post by Nicke » Tue May 20, 2014 9:53 am

Hi keram,

thanks I have to take a look at that approach, but I still have to figure out how to color the wanted line so that the hilite is still visible...

Nicke
Posts: 36
Joined: Thu Nov 28, 2013 11:19 am
Location: Helsinki, Finland

Re: Change datagrid backgroundcolor for a row from code

Post by Nicke » Fri May 23, 2014 7:53 am

The solution to my problem is found here http://forums.runrev.com/viewtopic.php?f=8&t=20455

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”