如何使用自定义格式化程序内置函数来调用非jqGrid单独函数?

我想知道如何让jqGrid自定义格式化程序调用单独的函数“test1”? 我在“test1”函数上得到一个未定义的错误。

脚本#1 ……

//colModel json objects... { name: 'Vin', index: 'Vin' }, { name: 'Links', index: 'Links', formatter: jqgridCellFormatterLink } //jqGrid formatter function... function jqgridCellFormatterLink(cellValue, options, rowObject) { return "Test"; } //non-jqGrid function function test1(parmVin) { alert(parmVin); } 

谢谢…

//脚本#2 ……

 //colModel json objects... { name: 'Vin', index: 'Vin' }, { name: 'Links', index: 'Links', formatter: function(cellValue,options,rowObject) { return "Test";} } beforeSelectedRow: function(rowid, e) { if (this.p.colModel[$.jgrid.getCellIndex($(e.target).closest("td")[0])].name === 'Links') { alert($('#blah').getCell(rowid, 0)); //Can be 0 or 'Vin'... } } 

我建议你使用答案和本节中描述的方法。 您不需要将onclick绑定到某个全局方法。 而不是使用onCellSelectonCellSelect回调更有效,它将在一个现有的 click事件句柄中调用。

顺便说一下,你发布的格式化程序可能不起作用,因为rowObject的格式取决于很多东西:你如何填充网格,你使用哪种datatype"local""json""xml"可以产生不同的格式of rowObject ),无论你使用的是rowObject repeatitems: true还是jsonReader其他一些设置,你是否使用loadonce等等。