Actions
Support #1974
closedConfigure background color for rows in a WTableView
Start date:
06/11/2013
Due date:
% Done:
0%
Estimated time:
Description
Hi all,
I use a WTableView to implement a logbook with row colors set according to event types.
Cell content is set with this code:
LogBook::LogBook(int rows, int columns, Wt::WObject *parent) : VirtualModel(rows, columns, parent) {
List_reset( 0 );
Wt::WApplication::instance()->styleSheet().addRule("option.myclass","background-color: red;");
}
boost::any LogBook::data(const Wt::WModelIndex& index, int role) const {
int color;
switch (role) {
case Wt::DisplayRole:
return Wt::WString(List_cell(0, index.row(), index.column(), &color));
/*
case Wt::StyleClassRole:
return Wt::WString("option.myclass");
break;
*/
default:
return boost::any();
}
}
The problem is that i dont know how to set the background color. I guess i have to return some clever information for the Wt::StyleClassRole role but i cant get it to work.
Thank you for your Help.
Regards,
Olivier
Updated by Koen Deforche almost 11 years ago
- Status changed from New to Feedback
- Assignee set to Koen Deforche
Hey oliver,
This should work provided you remove the '.' from the class name --- that's not allowed.
(The '.' is an operator in a style class selector to combine class names, see http://www.w3.org/TR/CSS2/selector.html#class-html)
Wt::WApplication::instance()->styleSheet().addRule(".option-myclass","background-color: red;");
case Wt::StyleClassRole:
return Wt::WString("option-myclass");
break;
Regards,
koen
Updated by Koen Deforche about 9 years ago
- Status changed from Feedback to Resolved
Updated by Koen Deforche about 9 years ago
- Status changed from Resolved to Closed
Actions