我正在嘗試動態綁定jqGrid列模型的格式器。我按照如下動態構建colModel
陣列。如何動態綁定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 });
}
這就是我之前所做的。數據庫中的格式化程序字段直接具有該功能。它沒有工作或者 – user1077595 2013-04-08 12:43:26