我的列正在显示,它正在为我的链接生成一个锚点。唯一的问题是网址形成错误的MVC
这是colModel:
colModel: [
{ name: 'RegName', index: 'RegName', label: 'Region Name',width:90, align: 'center' },
{ name: 'AccessNbr', index: 'AccessNbr', label: 'Access Number',width:80, align: 'center', formatter: 'showlink', formatoptions: {baseLinkUrl: '', showAction: 'GetBoxesForPorId', addParam: ''} },
{ name: 'TransmitedDt', index: 'TransmitedDt', label: 'TransmitedDt', align: 'center' },
{ name: 'BoxCount', index: 'BoxCount', label: 'Box Count', align: 'center' },
{ name: 'PorId', hidden:false ,index: 'PorId', label: 'Por ID', key:true ,formatter:'link', formatoptions: {target:'_new'} }
]
以下是它构建的网址: http://localhost:4618/Por/GetBoxesForPorId?id=16
我希望它构建的网址是: http://localhost:4618/Por/GetBoxesForPorId/16
答案 0 :(得分:12)
这是你的答案:
function formateadorLink(cellvalue, options, rowObject) {
return "<a href=/Idiomas/Edit/"+ cellvalue + ">" + cellvalue + "</a>";
}
网格定义中的:
colModel: [
{ name: 'id_idioma', index: 'id_idioma', width: 100, align: 'left',
formatter: formateadorLink
},
{ name: 'nombre', index: 'nombre', width: 100, align: 'left' }
],
答案 1 :(得分:1)
这就是我这样做的方式:
function LinkFormatter(cellvalue, options, rowObject) {
return '<a href= <%= Url.Content("~/") %>' + cellvalue + ">Edit</a>";
}
Col Model
colModel: [
{ name: 'Id', index: 'Id', width: 50, align: 'left', hidden: true },
{ name: 'Edit', index: 'Edit', width: 50, align: 'left', formatter: LinkFormatter },
{ name: 'AgentName', index: 'AgentName', width: 250, align: 'left' },
{ name: 'AgentType', index: 'AgentType', width: 250, align: 'left' },
],
在服务器端
var jsonData = new
{
total = 1,
page = 1,
records = agents.Count(),
rows = (
from row in agents
select new
{
i = row.Id,
cell = new[] {
row.Id.ToString(),
"Controller/Action/" + row.Id.ToString(),
row.Name,
row.Type
}
}).ToArray()
};