Bug #7740
closedsetValueStyleClass has no visual effect
100%
Description
Trying to change progress bar progress color based on progress value.
But i see it has no immediate effect. It requires page refresh.
Is it supposed to be like this or I am doing something wrong?
Please see below :
auto style = VELOCITY_MODEL.Overrange() ? "progress bg-danger-Polytec" : "progress bg-info-polytec";
m_velocityProgressBar->setValueStyleClass(style);
Wt::WApplication::instance()->triggerUpdate();
Updated by Korneel Dumon over 3 years ago
- Description updated (diff)
- Assignee changed from Koen Deforche to Korneel Dumon
- Priority changed from Immediate to Normal
Hi,
could be a few things. Do you see the style-class in the browser debugger? Or do you think triggerUpdate() does nothing?
To make server updates, you need to do a few things:
- call WApplication::enableUpdates() before-hand to make sure Wt keeps an open line to the client
- grab the update-lock (or use WServer::post)
- triggerUpdate() as you do
Updated by Mahmudul Hasan over 3 years ago
Korneel Dumon wrote in #note-1:
Hi,
could be a few things. Do you see the style-class in the browser debugger? Or do you think triggerUpdate() does nothing?
To make server updates, you need to do a few things:
- call WApplication::enableUpdates() before-hand to make sure Wt keeps an open line to the client
- grab the update-lock (or use WServer::post)
- triggerUpdate() as you do
I see the style is not changed. It's always as initiated(progress bg-info-polytec). But other properties are updated Like the progress value.
Updated by Korneel Dumon over 3 years ago
It seems WProgressBar::setValueStyleClass()
is not part of the public API (as it is not documented). After checking the code, I noticed that this function
does not trigger a repaint, which explains the behavior you see.
You're better off changing the style class on progress bar itself and making style rules that combine classes.
Updated by Mahmudul Hasan over 3 years ago
Korneel Dumon wrote in #note-3:
It seems
WProgressBar::setValueStyleClass()
is not part of the public API (as it is not documented). After checking the code, I noticed that this function
does not trigger a repaint, which explains the behavior you see.You're better off changing the style class on progress bar itself and making style rules that combine classes.
I am not sure if I understood your properly. Can you give me bit hint what you mean by making style rule?
I tried using the setStyleClass. But the danger color looks goes to the background.
auto style = m_velocityModel.Overrange() ? "bg-danger" : "bg-info";
m_velocityProgressBar->setStyleClass(style);
Updated by Korneel Dumon over 3 years ago
The style-rule should be something like:
.bg-danger .progress-bar { background-color: red; }
.bg-info .progress-bar { background-color: green; }
Note that I didn't test this, just trying to show you the idea.
Updated by Roel Standaert almost 2 years ago
- Status changed from New to Resolved
- Assignee deleted (
Korneel Dumon) - Target version set to 4.9.0
- % Done changed from 0 to 100
I merged PR 131, which should resolve this.
Updated by Roel Standaert almost 2 years ago
- Tracker changed from Support to Bug
Updated by Roel Standaert almost 2 years ago
- Status changed from Resolved to Closed