Skip to main content
15-Moonstone
April 30, 2021
Question

fixed decimal value

  • April 30, 2021
  • 4 replies
  • 1769 views

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?

4 replies

17-Peridot
April 30, 2021

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

Sruthi15-MoonstoneAuthor
15-Moonstone
April 30, 2021

Is there any other solution other than this?

17-Peridot
April 30, 2021

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

Community Manager
May 10, 2021

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

5-Regular Member
May 11, 2021

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.

5-Regular Member
May 24, 2021

@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