jQuery技术:如何使用自定义格式化程序内置函数来调用非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等等。

      以上就是jQuery教程分享如何使用自定义格式化程序内置函数来调用非jqGrid单独函数?相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/jquerytutorial/541392.html

      (0)
      上一篇 2021年1月3日
      下一篇 2021年1月3日

      精彩推荐