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.
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.
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?
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:
.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.
ptalbot:
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.