Keeping the currency formatted JQgrid cell blank w

2019-09-17 09:33发布

问题:

once of the the cells in my jqgrid is currency formatted with the formatoptions:{decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "$ ",defaultValue:''}

This is the case when I have a value for it But in cases where I don't have a value to that particular field Grid by default takes $0.00 I would like to keep it blank instead of filling with a default value ie $0.00

How can I do that? After looking up some question I went with the custom formatter

if (cellValue != 0.00) 


  {

    return $.fmatter.util.NumberFormat(closingAmount, $.jgrid.formatter.currency);

}
else
{

    return "";
}

in this case how can I add $ as the prefix?? and ofcourse sorting on this field is not working. Looking forward to a quick help and fix from someone thanks in advance!!

回答1:

You can use $.fn.fmatter.call(this, "currency", cellValue, options) inside of custom formatter instead of the usage of $.fmatter.util.NumberFormat.