Project

General

Profile

Actions

Bug #7740

closed

setValueStyleClass has no visual effect

Added by Mahmudul Hasan over 3 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
09/29/2020
Due date:
% Done:

100%

Estimated time:

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();

Actions #1

Updated by Korneel Dumon about 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

See also: https://webtoolkit.eu/wt/doc/reference/html/classWt_1_1WApplication.html#ad9631ca64e68d30d40cb49c90e55223d

Actions #2

Updated by Mahmudul Hasan about 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

See also: https://webtoolkit.eu/wt/doc/reference/html/classWt_1_1WApplication.html#ad9631ca64e68d30d40cb49c90e55223d

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.

Actions #3

Updated by Korneel Dumon about 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.

Actions #4

Updated by Mahmudul Hasan about 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);

Actions #5

Updated by Korneel Dumon about 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.

Actions #6

Updated by Roel Standaert over 1 year 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.

Actions #7

Updated by Roel Standaert over 1 year ago

  • Tracker changed from Support to Bug
Actions #8

Updated by Roel Standaert over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF