我在 mvc 3 中使用 jqgrid,我想在 JqGrid 的每一行中添加编辑和删除按钮,我通过这个链接实现了这个功能。但它是用于内联编辑的,我想在单击编辑按钮时打开一个弹出窗口。
我怎样才能做到这一点。
谢谢
我在 mvc 3 中使用 jqgrid,我想在 JqGrid 的每一行中添加编辑和删除按钮,我通过这个链接实现了这个功能。但它是用于内联编辑的,我想在单击编辑按钮时打开一个弹出窗口。
我怎样才能做到这一点。
谢谢
您应该只使用从 jqGrid 4.1.0 版本开始存在的新editformbutton: true选项:
formatter:'actions',
formatoptions: {
keys: true,
editformbutton: true
}
请在下面找到 colmodel 进行编辑:
{
name: 'EditAction',
width: 60,
fixed: true,
search: false,
sortable: false,
resize: false,
formatter: 'actions',
formatoptions: {
keys: false,
editbutton: true,
delbutton: false,
editformbutton: false,
onSuccess: function(response) {
if (response.status == 200) {
}
},
extraparam: { oper: 'edit' },
url: '@Url.Action("ActionName", "Controller")'
}
},
jQuery("#grid").jqGrid({ datatype: "local", data: second, @ url: '@Url.Action("orders", "Home")', datatype: "json", @ colNames: [ 'name', 'description', 'url'], colModel: [ {name: 'name', index: 'name', editable: true, editrules: {required: true}, editoptions: {placeholder: '输入名称'} }, {name: 'description', index: 'description', editable: true, editrules: {required: true}, editoptions: {placeholder: 'Enter description'} },
{
name: 'url',
index: 'url',
editable: true,
editrules: {required: true},
editoptions: {placeholder: 'Enter url'}
}
],
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'model',
pager: '#pager',
editrow:true,
editurl: '@Url.Action("orders", "Home")',
viewrecords: true,
sortorder: "desc",
jsonReader: {
repeatitems: false,
id: "0"
},
searching: {
loadFilterDefaults: false,
closeOnEscape: true,
searchOperators: true,
searchOnEnter: true
},
caption: "Cars Grid",
height: '80%',
gridComplete: initGrid
});