cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to change Label and Colour of button dynamically

plaban
6-Contributor

How to change Label and Colour of button dynamically

Hi,

Greetings!

We have a requirement to dynamically change the Label and Colour of a button based on the output of a service.

Can we do this?

I have also tried the workaround with Shape but it doesn't have text.

Any solution please?

Regards,

Plaban

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Folks,

The way to go with this kind of requirements are just the ValueDisplay widget, with it you can do everything he it's asking for.

Best Regards,

Carles.

View solution in original post

9 REPLIES 9
posipova
20-Turquoise
(To:plaban)

You could try a radiobuttion and state definitions, using a specific style for each state.

Alternatively, you may look into custom extensibility and developing or modifying existing widgets to feed style definitons based on the input.

ankigupta
5-Regular Member
(To:plaban)

Hi Plaban Patra​,

Have you tried placing the shape widget on a valueDisplay widget so that valueDisplay shows the text and ValueDisplay defines the color.

I hope it helps.

you can try creating two different buttons with desired colour and labels on it then depending on the service result can hide or show the button and will work fine.

Hi Folks,

The way to go with this kind of requirements are just the ValueDisplay widget, with it you can do everything he it's asking for.

Best Regards,

Carles.

ankigupta
5-Regular Member
(To:CarlesColl)

Ah! yes, missed that. ValueDisplay has both StateFormatting and text. So, we don't require separate widgets for this requirement. Thanks Carles Coll

That was helpful Carles Coll​ thanks i didn't knew that.

But What about the label on it, how to change it dynamically?

ValueDisplay accepts value binding you just need to return the desired text from a Service or a Expression Widget.

plaban
6-Contributor
(To:CarlesColl)

Thank you Carles Coll!

This solved the problem.

Top Tags