【发布时间】:2017-11-21 09:58:59
【问题描述】:
我如何在 jqGrid 的悬停行上显示图标(添加、编辑图标等),并通过单击我想调用 JS 函数等的图标。我想在每一行上显示图标。
下面是我的 jqGrid
$grid.jqGrid({
url: '@Url.Action("GetOrganizationList", "Organization")',
datatype: "json",
height: 'auto',
colNames: ['@objLocalizer["organization_organizationID"]','@objLocalizer["OrganizationsName"]', '@objLocalizer["ParentOrganization"]', '@objLocalizer["Email"]', '@objLocalizer["ContactPhone"]', '@objLocalizer["CurrencyID"]','@objLocalizer["CreatedByorg"]','@objLocalizer["CreatedOnorg"]']
colModel: [{
name: 'OrganizationID',
index: 'OrganizationID',
sortable: true,
sorttype: 'number',
formatter: addLink,
align: 'center'
},{
name: 'OrganizationName',
index: 'OrganizationName',
sortable: true,
sorttype: 'text',
}, {
name: 'PratentOrganization',
index: 'PratentOrganization',
sortable: true,
sorttype: 'text',
align: 'left'
},
{
name: 'ContactEmail',
index: 'ContactEmail',
sortable: true,
sorttype: 'text',
hidden: true,
},
{
name: 'ContactPhone',
index: 'ContactPhone',
sortable: true,
sorttype: 'text',
hidden: true,
},
{
name: 'CurrencyID',
index: 'CurrencyID',
sortable: true,
sorttype: 'text',
hidden: true,
},
{
name: 'UserName',
index: 'UserName',
sortable: true,
sorttype: 'text',
align: 'left'
},
{
name: 'WhenCreated',
index: 'WhenCreated',
sortable: true,
sorttype: 'text',
formatter: 'date',
align: 'center'
}
],
cmTemplate: { autoResizable: true, editable: true },
autoResizing: { compact: true, resetWidthOrg: true },
iconSet: "fontAwesome",
rowNum: 10,
rowList: [5, 10, 20, "10000:All"],
viewrecords: true,
sortable: true,
toppager: false,
pager: true,
rownumbers: false,
sortname: "invdate",
sortorder: "desc",
pager: '#pjqgridOrg',
pagerRightWidth: 150,
loadonce: true,
multiselect: false,
hidegrid: false,
gridComplete: function () {
},
}).jqGrid("navGrid")
.jqGrid("inlineNav")
.jqGrid("filterToolbar");
第一列“OrganizationID”的格式化程序
function addLink(cellvalue, options, rowObject) {
var validrow = rowObject.Organization;
if (validrow != undefined) {
return "<a href='#' style='height:25px;width:120px;' type='button' onclick=CallActionMethod(" + "'" + OrganizationID + "'" + ")>" + OrganizationID + "</a>";
} else {
return "<a href='#' style='height:25px;width:120px;' type='button' onclick=CallActionMethod(" + "'" + rowObject['OrganizationID'] + "'" + ")>" + rowObject['OrganizationID'] + "</a>";
}
}
下面是截图,它的样子
我想在第一列即“OrganizationID”列中显示图标。
【问题讨论】:
标签: jquery jqgrid free-jqgrid