Page 1 of 1

Form Data Grid - Setting Background Row Color

Posted: Thu Nov 14, 2013 10:06 pm
by Tester2
Is there a way to change the background color on specific rows of a form data grid?

Ex: If I want row 1 and 5 to have a background color of white, but the other rows (2,3,4,6,7) to have background colors of red - how would I accomplish this?

I tried the code below, but it did not work:

set the backgroundcolor of line 2 of grp "DataGrid 1" of grp "Scroller" to 248,247,249

Thanks!

-Milo

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 2:50 am
by Jellicle
What I would do is place a coloured graphic object behind everything else in the Row Template group, sized the same as the group.

I'm assuming there is some condition that needs to be met for the graphic to show - when it's met for the record do:

Code: Select all

set the visible of graphic "redBackground" of me to true
Gerry

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 3:27 am
by Tester2
Gerry,

Thanks so much for the response!

I am just trying to color certain rows indefinitely - they will not change color based on a condition.

I have some rows that I am just using as Headers.

Example:

Row 1: Introduction
Row 2: Video 1
Row 3: Video 2
Row 4: Video 3
Row 5: Overview
Row 6: Video 4
Row 7: Video 5

In this example, I want to have the background color for Row 1 and Row 5 to be white….but the other rows to have a background color of blue.

Thanks for your help!

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 3:58 am
by Simon
Hi Tester2,
I think Gerry's answer still holds true.
Just add a graphic, show it for rows 1-5 hide it for the rest. Somewhere in your preOpenCard maybe?

Simon

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 4:14 am
by Tester2
Thanks for the comment Simon…I'm hoping you are correct!

I added a "redBackground" graphic in my Row Template group.

I think that I am maybe using the wrong terminology in my code.

This is the command I am trying to use to set the 3rd row's background to red:

set the visible of line 3 graphic "redBackground" of grp "DataGrid 1" of grp "Scroller1" to true

Side Note: I have a Form Data Grid (DataGrid 1) inside of a MobGui Scroller (Scroller1).

Thanks!

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 4:45 am
by Jellicle
You do have a condition: is this row a header record or is it not? If it's a video - show the blue background. If it's not...hide it.

I assume you are filling the data grid with an array? And that you are using the Data grid template Behaviour Script to place the array data into fields? Your code to show or hide the background graphic goes in that behaviour script.

Your array should contain a field (say "rowtype") that specifies whether the row is a header or not. A true/false flag in that field will do.

Then in the behaviour script you need to check which record in the array is currently being processed and if it is one of your header rows then hide the background graphic, else show it.

And your code (in the LayoutControl handler) would be something like:

Code: Select all

if pDataArray["rowtype"] = "false" then
 set the visible of graphic "blueBackground" of me to false
else
set the visible of graphic "blueBackground" of me to true
end if
Gerry

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 4:52 am
by Jellicle
...or are you wanting to set those row colours from outside the data grid behaviour script?

Gerry

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 6:14 am
by Tester2
Gerry,

These little grids are much bigger than I expected! lol

I explored your option and after some testing and modifying was able to get it to work! :)

I think I just need some more experience with them, and it will get easier.

Thanks a million for your help!

-Milo

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 1:07 pm
by Klaus
See Milo, professional help is guaranteed when:
1. not hijacking another thread and
2. posting in the correct forum
:D

Re: Form Data Grid - Setting Background Row Color

Posted: Fri Nov 15, 2013 11:52 pm
by Jellicle
Milo

Datagrids have a steep learning curve, but are totally worth it :)

Gerry