Skip to main content
15-Moonstone
Question

fixed decimal value

Hi,

I am displaying some properties(decimal values) in property display widget. I need to restrict the values after decimal to 2 digits. How to achieve this in property display widget?

6 replies

17-Peridot

Hi @Sruthi,

 

JS code like below can be used in service to restrict the values after decimal to 2 digits:

var num =2.446242342;
num = num.toFixed(2)

 

Thanks,

/Yoyo

Translate
Sruthi15-MoonstoneAuthor
15-Moonstone

Is there any other solution other than this?

Translate
17-Peridot

Hi @Sruthi,

 

I don't think there is any other solution except this, because we can only consider to restrict the decimal in service or mashup widget. The value display widget doesn't have this function in OOTB, so we can only consider to define that through service output. 

Or you need to consider customization on widget.

 

Thanks,

/Yoyo

Translate
Support

Hi @Sruthi.

 

If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Translate
5-Regular Member

Hi @Sruthi 

 

I believe this thread is duplicate of https://community.ptc.com/t5/ThingWorx-Developers/fixed-decimals/m-p/727636#M51930

 

Could you please check and mark one of them as accepted solution if your already receive the solution.

Translate
5-Regular Member

@Sruthi 

 

Hi, In my last response i have posted the duplicate thread of this thread which is already marked as accepted solution. Could you please park this post accepted solution as well for the benefit of other community user and to avoid any confusion in future.

 

Regards,

Mohit

Translate