Confused about how to replace rowBGColorCalculation

Questions and answers for designing and implementing forms in Servoy

Confused about how to replace rowBGColorCalculation

Postby SteveInLA » Sat Aug 18, 2012 3:47 pm

I am upgrading my solutions to Servoy 6.1 and having trouble getting the same functionality I had from rowBGColorCalculation using CSS and/or onRender. In my solutions, I have some forms where I want the row background to alternate and the selected row to be a different color, and achieving that is easy enough using the odd, even, selected example in the style sheet. The problem is that I also have forms where I want to list records and not alternate the background, and rows where I do not want to alternate the background, but want to change the color for the selected record. Without the ability to specify a unique rowBGColorCalculation for individual forms, I am not sure how this is done anymore.

I can see how creating individual styles for the various types of list forms would be one method, but that seems inefficient since I would also have to re-define the styles for labels, buttons, fields, etc. Also, for some reason, attaching a method to the onRender event of a form seems to change the bgColor for every element on the form EXCEPT the row background, so all my buttons and fields change color, which is not what I want. It seems that most of the examples and posts deal with forms in tableView and the Web Client and I primarily use listView and the Smart Client.

I look forward to your suggestions.
Steve in L.A.
SteveInLA
 
Posts: 233
Joined: Thu Jul 29, 2004 12:00 am
Location: Southern Oregon, USA

Re: Confused about how to replace rowBGColorCalculation

Postby ptalbot » Sat Aug 18, 2012 5:05 pm

You can easily have more than one style sheet... Just duplicate your main style sheet and change only the odd/even/selected style, then apply the style sheet you want for each form.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Confused about how to replace rowBGColorCalculation

Postby Thomas Parry » Sat Aug 18, 2012 5:33 pm

I too have similar needs and found that the change to css is not always what I want. So rather than retaining the deprecated RowBColourCalculation I am moving to the css.
However, duplicating style sheets also seems inefficient when the CSS should be able to be used to specify subsets of odd, even and selected. Perhaps Servoy could enhance the feature? Perhaps you could raise the request?
Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada

Re: Confused about how to replace rowBGColorCalculation

Postby ptalbot » Sat Aug 18, 2012 6:04 pm

Actually, without changing the style sheet, you can also do that by using a style class in front of the odd/even/selected, for example:

Code: Select all
.one odd, .one even, .one selected {
   background-color: #FFF;
   color: #5C5C5D;
}

.one odd {
   background-color: #F5F7F9;
}

.one even {}

.one selected {
   background-color: #d4d4d4;
   color: #FFF;
}

.two odd, .two even, .two selected {
   background-color: #CCC;
   color: #EEE;
}

.two odd {
   background-color: #FF00FF;
}

.two even {}

.two selected {
   background-color: #00FFFF;
   color: #FFF;
}

form.one {
}

form.two {
}


Then set your table view/list view form styleClass to 'one' or 'two'...
Works fine here.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Confused about how to replace rowBGColorCalculation

Postby SteveInLA » Sat Aug 18, 2012 11:35 pm

ptalbot wrote:Actually, without changing the style sheet, you can also do that by using a style class in front of the odd/even/selected


Thanks Patrick. I actually found out about that technique shortly after posting this and that does seem to be the best way to handle this situation.
Thanks again!

Steve in L.A.
SteveInLA
 
Posts: 233
Joined: Thu Jul 29, 2004 12:00 am
Location: Southern Oregon, USA


Return to Forms

Who is online

Users browsing this forum: No registered users and 6 guests