Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi using a plugin called jqwidgets, and I have a jqxgrid using cellsrenderer, an

ID: 3781126 • Letter: H

Question

Hi using a plugin called jqwidgets, and I have a jqxgrid using cellsrenderer, and I was able to put the negative sign before dollar sign using custom cell rendering. But now I cannot get the values after the decimal point. So like now it shows -$370 but I want it to show -$370.00 or -$370.25. This same goes for the positive values too. The values after the decimal points are not showing.

Also suppose you did inline edit so like you edited -$370 to -$370.20, for some reason it updates to -$370.2, the "0" is not showing up

http://jsfiddle.net/42y0cs1a/4/

Explanation / Answer

Hi,

It is because, the variable 'answer' which is embedding between span (<span>$' + answer + '</span>' ) is in 'number' format; to be specific, in float datatype. Changing the variable to string format will fix the problem and matches your requirement. For that, we will be using 'toFixed(<precision>)' function which inherently converts number datatype to string after adding decimal.

So, the fix would be:

<span>$' + answer.toFixed(2) + '</span>'

I already updated the solution to the same jsfiddle link. Pls check.

Thank you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote