0
我想知道如何让jqGrid自定义格式化程序调用一个单独的函数,“test1”? “test1”函数出现未定义的错误。如何让自定义格式化程序内置函数调用非jqGrid分离函数?
脚本#1 ...
//colModel json objects...
{ name: 'Vin', index: 'Vin' },
{ name: 'Links', index: 'Links', formatter: jqgridCellFormatterLink }
//jqGrid formatter function...
function jqgridCellFormatterLink(cellValue, options, rowObject) {
return "<span onclick='test1(\"" + rowObject[0] + "\");'>Test</span>";
}
//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 "<span>Test</span>";} }
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'...
}
}
不错!现在我得到了使用jqGrid beforeSelectRow对象的“test1”函数。现在,我如何将单元格值传递给jqGrid beforeSelectRow对象中的“test1”函数?谢谢。 – fletchsod
@fletchsod:不客气!你现在用哪种方式?代码在哪里?如果你做得正确,你会得到'e'(事件)作为参数。你可以从'e.target'获得**所有需要的信息**。 – Oleg
我刚刚更新了上面的脚本。我把它们写在纸上,然后由于内联网的限制,在特定的计算机上输入。我正在使用数据类型:json。不使用重复项。我正在使用loadonce:true。希望我的描述够好。 – fletchsod