我是MVC的初学者。我有一个必须显示为图片的列(现在是一个文本),当用户点击图片时,它会显示带有新视图的对话框。正如我用Google搜索,我只能使用格式化程序一次,我应该用它来实现它?
{ name: 'SimType', label: 'SimType', template: columntemplates.textTemplate, width: 50, editable: true, editrules: { edithidden: false }, formatter: linkFormat2, unformat: linkUnFormat2, editoptions: { disabled: 'disabled' } },
function linkFormat2(cellvalue, options, rowObject)
{
var linkUrl = '@Url.Action("GetMobilePhoneModels", "MobilePhoneModel", new { phonenumber = "Id" })'.replace('Id', rowObject['PhoneNumber']);
return '<span class="MobilePhoneModel"><a href="' + linkUrl + '">' + cellvalue + '</a></span>';
}
或
function linkFormat2(cellvalue, options, rowObject)
{
var cellValueInt = parseInt(cellvalue);
if (cellValueInt = "mobile")
return "<img src='../../Content/Images/Devices/mobile.png' width='11px' height='20.75px' alt='" + cellvalue + "' title='" + cellvalue + "' />";
}
它分开工作,但不可能一起工作。
感谢任何帮助。感谢。
答案 0 :(得分:0)
function linkFormat2(cellvalue, options, rowObject) {
var cellValueInt = parseInt(cellvalue);
if (cellValueInt = "mobile")
{
var linkUrl = '@Url.Action("GetMobilePhoneModels", "MobilePhoneModel", new { phonenumber = "Id" })'.replace('Id', rowObject['PhoneNumber']);
return '<span class="MobilePhoneModel"><a href="' + linkUrl + '"><img src="../../Content/Images/Devices/mobile.png" width="11px" height="20.75px" alt="' + cellvalue + '" title="' + cellvalue + '" /></a></span>';
}
}