Form Data Grid - Setting Background Row Color
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Form Data Grid - Setting Background Row Color
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
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
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:
Gerry
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
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Form Data Grid - Setting Background Row Color
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!
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
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
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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Form Data Grid - Setting Background Row Color
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!
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
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:
Gerry
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
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Form Data Grid - Setting Background Row Color
...or are you wanting to set those row colours from outside the data grid behaviour script?
Gerry
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Form Data Grid - Setting Background Row Color
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
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
See Milo, professional help is guaranteed when:
1. not hijacking another thread and
2. posting in the correct forum

1. not hijacking another thread and
2. posting in the correct forum

Re: Form Data Grid - Setting Background Row Color
Milo
Datagrids have a steep learning curve, but are totally worth it
Gerry
Datagrids have a steep learning curve, but are totally worth it

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.