I am trying to bind the formatter for the jqGrid column Model dynamically. I build the colModel
array dynamically as follows.
ColModel:[{name:Id,width:50,formatter:customerLinkFormatter}]
I have extended the formatter as follows
$.extend($.fn.fmatter, {
customerLinkFormatter: function (cellvalue, options, rowdata) {
return '<a href="CustomerEdit.aspx?id=' + rowdata[options.colModel.name] + '"> ' + cellvalue + '</a>';
}
});
But no link is displayed for the Id column. Please help me in figuring out.
Here is part of the code
$(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 });
}