DataGrid-How do I set a certain row a certain color

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jschaube
Posts: 7
Joined: Thu Jan 24, 2008 1:13 am
Contact:

DataGrid-How do I set a certain row a certain color

Post by jschaube » Tue Oct 13, 2009 5:40 pm

In a DataGrid, I would like to set a certain row a certain color when one of it's cells has the word "Critical" in it. How do I do this?
Jim...

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

Post by trevordevore » Tue Oct 13, 2009 6:46 pm

This lesson from the manual shows how to colorize text in a row based on a value in the table.

How Can I Colorize Individual Lines in a Table?
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

jschaube
Posts: 7
Joined: Thu Jan 24, 2008 1:13 am
Contact:

Post by jschaube » Tue Oct 13, 2009 8:09 pm

Thanks Trevor...It works perfectly when I start a main stack from scratch but when I'm using your scripts on a stack I've already built (IE-following Kevin's script on setting the icons of the "country" buttons to flags) I can not get your script to work. His process has me creating column behaviors. Would this make your scripts break because I already have column behaviors?

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

Post by trevordevore » Tue Oct 13, 2009 8:14 pm

If you create column behaviors then you have to customize the script of each column behavior so that it colored the line. The issue is that creating a custom column template uses it's own behavior. This means that the default column behavior is no longer used.

Try customizing each column script right now (assuming you don't have too many) and see it you can get it working. If you do and want to consolidate code then let me know and I can point out some possibilities.
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

jschaube
Posts: 7
Joined: Thu Jan 24, 2008 1:13 am
Contact:

Post by jschaube » Tue Oct 13, 2009 8:33 pm

After I sent the post I figured I could modify each column behavior as you mentioned. Since you verified that thought, I feel much better about taking the time to do so :-)...I have 12 columns so no problem

Thanks for the timely responses !!!

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

Post by trevordevore » Tue Oct 13, 2009 8:37 pm

Glad you got it working.

You can always consolidate scripts by assigning the behavior property of the custom column templates to the same button. This would effectively share the same script among all columns. Of course this would mean adding an if/then or switch statement in your behavior script based on the column that was being targeted.
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

Post Reply