自定义删除功能中的jqGrid [英] Custom Delete Function in jqGrid
问题描述
我想自定义的jqGrid删除功能。
I am trying to customize the delete function in jqGrid.
我已经启用了对电网的删除按钮
I have enabled the delete button on the grid
$("#myGrid").jqGrid('navGrid', '#pager',
{ add: true, addtitle: 'Add Customer',
edit: true, edittitle: 'Edit Customer',
del: true, deltitle: 'Delete Customer',
refresh: true, refreshtitle: 'Refresh data',
search: true, searchtitle: 'Apply filters',
addfunc: addForo, editfunc: editForo,
cloneToTop: true
},
{}, // default settings for edit
{}, // default settings for add
{}, // default settings for delete
{ closeOnEscape: true, multipleSearch: true, closeAfterSearch: true }, // search options
{} // default settings for view
);
然后我加入(感谢这个帖子)以下的$ C $ ç
then I have added (thanks to this post) the following code
$("#bDelete").click(function () {
// Get the currently selected row
toDelete = $("#myGrid").jqGrid('getGridParam', 'selrow');
$("#myGrid").jqGrid(
'delGridRow',
toDelete,
{ url: '/Foro/Delete/' + toDelete, mtype: 'post', reloadAfterSubmit: false }
);
});
现在,当我点击删除按钮将显示一个对话框,要求删除确认。但如果我点击删除按钮,我会收到以下错误消息
Now when I click on the delete button a dialog is shown asking for delete confirm. But if I click on the delete button I will get the following error message
我在哪里错了?
推荐答案
如果我理解你纠正你要修改的网址
用于删除行,这样的ID该行会在网址
的一部分。你可以这样做很容易:
If I understand you correct you want to modify the url
used to delete of row so that the id of the row will be a part of the url
. You can do this much easier:
$("#myGrid").jqGrid('navGrid', '#pager',
// define navGrid options and paraneters of Edit and Add dialogs
{ // now define settings for Delete dialog
mtype: "POST", reloadAfterSubmit: false,
onclickSubmit: function(rp_ge, postdata) {
rp_ge.url = '/Foro/Delete/'+ postdata;
},
serializeDelData: function (postdata) { return ""; }
},
// search options
// ...
);
对于 onclickSubmit
的我们可以通过修改网址
和界定 serializeDelData
我们可以明确的POST消息的正文。我peronally大多是在服务器端使用REST风格的服务,并使用 MTYPE:删除
。在这种情况下,清除身体真正需要的。
With respect of onclickSubmit
we can modify the url
and defining of serializeDelData
we can clear the body of the "POST" message. I peronally mostly use RESTfull services on the server side and use mtype: "DELETE"
. In the case to clear of the body is really needed.
还有一个选择是使用 delfunc
像你已经使用 editfunc
和 addfunc
。在大多数情况下,是不是真的需要这样的功能的使用,并可以实现相同的其他方式。
One more option is to use delfunc
like you already use editfunc
and addfunc
. In the most cases the usage of such function is not really needed and one can implement the same in other way.
这篇关于自定义删除功能中的jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!