php - Jqgrid custom format use bracket() if negatif value -
is solution in jqgrid if there negative number show bracket "()"
?
ex: show (23) if value -23
thanks
you can use custom formatter want. format numbers or integers correctly can call $.fmatter.util.numberformat
method $.jgrid.formatter.number
or $.jgrid.formatter.integer
second parameter. example of formetter is
formatter: function (cellvalue, options) { var value = parsefloat(cellvalue), retult, op = $.extend({}, $.jgrid.formatter.number); // or $.jgrid.formatter.integer if(!$.fmatter.isundefined(options.colmodel.formatoptions)) { op = $.extend({}, op,options.colmodel.formatoptions); } retult = $.fmatter.util.numberformat(math.abs(value), op); return (value >= 0 ? retult : '(' + retult + ')') + ' €'; }
you can additionally change color or other css style of displaying of negative numbers. can use cellattr
property add class
or style
attribute in cells negative numbers:
cellattr: function (rowid, cellvalue) { return parsefloat(cellvalue) >= 0 ? '' : ' style="color:red;font-weight:bold;"' }
the demo demonstrate settings. results following
Comments
Post a Comment