检索jqgrid复选框列值

时间:2011-05-18 19:12:23

标签: jqgrid checkbox

尝试检索在jqgrid中选中其复选框的记录的id列。我在下面的代码中显示了复选框列。

{ name: 'checkbox', index: 'checkbox',  formatter: "checkbox", formatoptions: { disabled: false }, editable: true, edittype: "checkbox" }

以及下面的代码来编辑选定的jqgrid行

jQuery('#list').editRow(id, true, formatEditors);

我的问题是,在点击提交/任何按钮后,如何(并且我不确定是否可以)浏览jqgrid中的所有选定记录? 所以在我的控制器(mvc2)中的事件处理程序中,我想访问在jqgrid中选择的记录的所有id值。

此外,我已经浏览了asp.net mvc 2 jqgrid add record中的代码,我可以显示添加按钮,但我无法检索用户选择的行(复选框)

任何帮助将不胜感激,因为我无法找到类似的例子。 在此先感谢!

1 个答案:

答案 0 :(得分:2)

这是我最后整理的答案

 for (var i = 0; i < inputs.length; i++) {

                if (inputs[i].type == 'checkbox' && inputs[i].checked) {

                    var p = inputs[i].parentNode.parentNode;
                    var id = p.id;

                           $.ajax({
                           mtype: "POST",
                           url: '<%= Url.Action("action") %>',
                            data: { actionparameter: id },
                           contentType: "application/json; charset=utf-8",
                           dataType: "json",
                           async: false,
                           cache: false

              }); 
              }
          }

用户还应该创建一个按钮并在该按钮的jquery中添加上面的代码,该动作将只是一个在控制器中执行该过程的动作,我希望这有帮助!