我正在尝试动态绑定 jqGrid 列模型的格式化程序。colModel
我如下动态构建数组。
ColModel:[{name:Id,width:50,formatter:customerLinkFormatter}]
我已将格式化程序扩展如下
$.extend($.fn.fmatter, {
customerLinkFormatter: function (cellvalue, options, rowdata) {
return '<a href="CustomerEdit.aspx?id=' + rowdata[options.colModel.name] + '"> ' + cellvalue + '</a>';
}
});
但没有显示 Id 列的链接。请帮我弄清楚。
这是部分代码
$(document).ready(function () {
"use strict";
$.ajax({
type: "POST",
url: "../Hdlr.ashx?",
datatype: "json",
success: function (msg) {
jqcolNames = msg.ColNames,
jqcolModel = msg.ColModel,
PopulateGrid();
},
error: function (msg) {
alert(' error ' + msg.responseText);
}
});
});
function PopulateGrid() {
$('#list').jqGrid({
url: "../Hdlr.ashx?",
colNames: jqcolNames,
colModel: jqcolModel,
jsonReader: {
cell: "",
id: "0",
repeatitems: false
},
rowNum: 10,
rowList: [10, 20, 30],
pager: "#pager",
rownumbers: true,
viewrecords: true,
search: false,
caption: "Grid Information"
}).jqGrid("navGrid", "#pager", { edit: false, add: false, del: false, search: false });
}