jqGrid:在自定义格式化程序中使用预定义的格式化程序

Shu*_*Shu 2 javascript jquery jqgrid

我想在自定义格式化程序中使用预定义的格式化程序.

例如,这是colModel:

colModel: [
  ...
  { name: 'col1', formatter: myFormatter }
  ...
]
Run Code Online (Sandbox Code Playgroud)

这是格式化程序:

function myFormatter(cellValue, options, rowObject) {
  if (typeof cellValue === 'number') {
    // Here I want to call the "currency" predefined formatter on the cellValue

  } else {
    return 'No number to display';
  }
}
Run Code Online (Sandbox Code Playgroud)

可能吗?谢谢.

Man*_*ijn 5

是的,你可以通过电话来做到这一点

return $.fmatter.util.NumberFormat(cellValue, $.jgrid.formatter.currency)
Run Code Online (Sandbox Code Playgroud)