:
当用户点击链接公式 1 时,我想重定向到 http://en.wikipedia.org/wiki/7
而不是http://en.wikipedia.org/wiki/Formula 1
其中 7 是公式 1 的 id
我的 JSON 响应如下
{"rows":[{"id":7,"person":"Michael Schumacher","type":"Sport","name":"Formula 1"},
{"id":8,"person":"Lukas Podolski","type":"Sport","name":"Football"},
{"id":9,"person":"Blaise Pascal","type":"Sport","name":"mathematics"},
{"id":6,"person":"Albert Einstein","type":"Sport","name":"Physics"}]}
jqgrid的代码是
jQuery("#list2").jqGrid({
url:"***.****",
datatype: "json",
mtype: 'GET',
colNames:['Name','Category','Subcategory'],
colModel:[
{name:'person',index:'person', width:150},
{name:'type',index:'type', width:150},
{name:'name',index:'name', width:150,
formatter: function (cellvalue, options, rowObject) {
var cellPrefix = '';
return cellPrefix + '<a href="http://en.wikipedia.org/wiki/' + cellvalue + '">' +
cellvalue + '</a>';
}}
],
width:"647px",
caption:"How to create custom Unobtrusive links"
});