如何在此ace admin jqgrid表中实现多行选择?(How to implement multi row select in this ace admin jqgrid table?)

我正在使用这个使用jqGrid的ace管理动态表模板。 我设法从数据库加载数据,并执行单行编辑和删除操作。 但是,即使模板提供多行选择功能,我也无法进行多行删除。 编辑,删除查询没有问题。 问题是多行ID没有通过。

jQuery(grid_selector).jqGrid({ // code to fetch dynamic JSON data editurl: "edit.php", multiselect: true, // some other code });

在edit.php文件中

switch ($_POST["oper"]) { case "add": // do mysql insert statement here break; case "edit": // do mysql update statement here break; case "del": // do mysql delete statement here break; }

在选择多个复选框并单击删除图标时,会触发以下事件(该事件已存在于模板中)。

$(t, w).attr({ title: m.deltitle || "", id: e.id || "del_" + v }).click(function() { if (!$(this).hasClass(k.disabled)) { var a; o.p.multiselect ? (a = o.p.selarrrow,0 === a.length && (a = null)) : a = o.p.selrow,a ? $.isFunction(m.delfunc) ? m.delfunc.call(o, a) : $(o).jqGrid("delGridRow", a, e) : ($.jgrid.viewModal("#" + n.themodal, { gbox: "#gbox_" + $.jgrid.jqID(o.p.id), jqm: !0 }), $("#jqg_alrt").focus()) } return !1 })

我一直在阅读模板的代码几个小时,但我很难理解,因为我是一个初学者。 请建议如何做多选。

I am using this ace admin dynamic table template which uses jqGrid. I managed to load data from database, and perform single row edit and delete operations. However I am not able to do multi row delete even though the template provides multi row select facility. There are no issues with edit,delete queries. The problem is multiple row id's are not getting passed.

jQuery(grid_selector).jqGrid({ // code to fetch dynamic JSON data editurl: "edit.php", multiselect: true, // some other code });

In edit.php file

switch ($_POST["oper"]) { case "add": // do mysql insert statement here break; case "edit": // do mysql update statement here break; case "del": // do mysql delete statement here break; }

On selecting multiple check-boxes and clicking the delete icon, the following event (which was already present in the template) is fired.

$(t, w).attr({ title: m.deltitle || "", id: e.id || "del_" + v }).click(function() { if (!$(this).hasClass(k.disabled)) { var a; o.p.multiselect ? (a = o.p.selarrrow,0 === a.length && (a = null)) : a = o.p.selrow,a ? $.isFunction(m.delfunc) ? m.delfunc.call(o, a) : $(o).jqGrid("delGridRow", a, e) : ($.jgrid.viewModal("#" + n.themodal, { gbox: "#gbox_" + $.jgrid.jqID(o.p.id), jqm: !0 }), $("#jqg_alrt").focus()) } return !1 })

I have been reading the template's code for hours, but I can hardly understand it since I am a beginner. Please suggest how to do multiple select.

最满意答案

我想你只需要实现正确的代码, case "del" :你的服务器代码( edit.php )的一部分。 jqGrid将发送逗号分隔的rowid列表到服务器。 因此你应该分割id参数的值,它将被发送到edit.php并且分别删除所有的数据。

I suppose that you need just implement correct code in case "del": part of your server code (edit.php). jqGrid will send comma separated list of rowids to the server. Thus you should split the value of id parameter, which will be send to edit.php and delete separately all the data.

更多推荐