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

enter image description here


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -