【发布时间】:2016-01-05 09:07:32
【问题描述】:
我在我们的网站上有一个供内部使用的 jqGrid,它列出了我们所有的用户。在每个用户/行上,我希望能够应用各种选项(取决于该行中的数据)。与其向寻呼机添加导航按钮,不如在右键单击一行时出现一个上下文菜单更有意义。
我们目前在我们的网站上导入了this jQuery contextMenu plugin,因此最好以某种方式将其集成到我的 jqGrid 中。
我的 jqGrid 缩小到基础看起来像这样:
$("#users").jqGrid({
datatype: 'json',
url: 'myMethodURL',
gridview: true,
colModel: [
{name: 'id', label: 'User ID', hidden:true},
{name: 'lastname', label: 'Last Name'},
{name: 'firstname', label: 'First Name'},
{name: 'status', label: 'Status', stype: 'select', searchoptions: {value: ':All;ACTIVE:Active;INACTIVATED:Inactive;PENDING APPROVAL:Pending Approval;'}},
... more fields ...
],
height:'auto',
autowidth:true,
caption:'Users',
rowNum:20,
rowList:[10,20,50],
sortorder:'asc',
sortname: 'lastname',
ignoreCase: true, // case-insensitive filtering
pager: '#pager',
jsonReader: {
root: "ROWS", //our data
page: "PAGE", //current page
total: "TOTAL", //total pages
records:"RECORDS", //total records
cell: "", //not used
id: "0" //will default first column as ID
},
postData: postData
});
$("#users").jqGrid("filterToolbar", {searchOnEnter: true});
上下文菜单中我需要的一些选项:
- 激活或停用(取决于用户当前是否处于活动/非活动状态 - 基本上需要切换)
- 处理待处理用户(应仅在用户状态为“待处理”时显示)
- 编辑用户信息
- 发送重置密码链接
如何设置带有可变选项的上下文菜单(取决于该特定行的值),并定义单击选项时会发生什么?
【问题讨论】:
标签: jquery jqgrid contextmenu