Hi using a plugin called jqwidgets and I have a jqxgrid usin

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 when I tried to implement using a custom thousand and decimal separator, The negative sign comes after the dollar sign and the commas are not placing correctly. The positive values work. But the negative values have problem with the negative sign placement which it should be before the dollar sign, and the commas are placing incorrectly too. Please check

Here is my customed jsfiddle:
http://jsfiddle.net/bj0pew16/1/

Solution

As per my knowledge about the above plugin, it is not allowed to put negative values in any row. however if you want to show it only in any way, follow this code:

You can modify your custom method for calories value less than 0 as

if (value <= 0) {
var val = value.toString(); //new variable to take the value as string
if(val.charAt(0) === \"-\"){ //checks if it has negative sign
val = val.substr(1); //clear out that as it is adding the sign in number string
}
var num2 = val.split(\'.\'); //follow your code
var thousands = num2[0].split(\'\').reverse().join(\'\').match(/.{1,3}/g).join(\',\');
var decimals = (num2[1]) ? \'.\' + num2[1] : \'\';
var answer = thousands.split(\'\').reverse().join(\'\') + decimals;
return \'<span style=\"margin: 4px; float: \' + columnproperties.cellsalign + \';\">-$\' + answer + \'</span>\';
       }
       else
       {
       var num2 = value.toString().split(\'.\');
var thousands = num2[0].split(\'\').reverse().join(\'\').match(/.{1,3}/g).join(\',\');
var decimals = (num2[1]) ? \'.\' + num2[1] : \'\';
var answer = thousands.split(\'\').reverse().join(\'\') + decimals;
return \'<span style=\"margin: 4px; float: \' + columnproperties.cellsalign + \';\">$\' + answer + \'</span>\';
       }

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 rende

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site