选择多行和单个行的选项

时间:2014-04-14 07:42:13

标签: asp.net-mvc-3 asp.net-mvc-4 jqgrid jqgrid-asp.net

我正在使用JQGrid,我想要一个多行选择的选项。我用了#34; multiselect:true,"但它不起作用。是的我在网格中有一个列,每行都有复选框,但是如果我选择顶部的复选框,它只是从网格中选择第一行

即使单行选择也无法正常工作。如果在一个复选框中选中,则选择,然后如果我检查另一行中的另一个框,则取消选中第一个选中的复选框。

这是我的网格代码。

 $(document).ready(function () {
            $("#btnGetdetails").click(function () {
                bindReports();
            });
            var bindReports = function () {
                $('#list1').jqGrid('GridUnload');
                $("#list1").jqGrid({
                    url: "GetNotesReportDetails",
                    postData: { startDate: $('#startDate').val(), endDate: $('#endDate').val(), ins_Type: $("#InsuranceType").val(), ass_Clincian: $("#ddlAssignedClician").val() },
                    datatype: "json",
                    mtype: "POST",
                    colNames: ["ID", "#", "First Name", "Last Name", "Date Of Birth", "Date of Visit", "Insurance Type", "Insurance ID","Clinician" ,"Procedure Code", "Fee Schedule"],
                    colModel: [
                            { name: "ID", index: "ID", hidden: true, key: true },
                            { name: "SNo", index: "SNo", width: 10, align: "left" },
                            { name: "FirstName", index: "FirstName", width: 40, align: "left", sortable: true, formatter: 'showlink', formatoptions: { baseLinkUrl: 'javascript:', showAction: "Link('", addParam: "');" } },
                            { name: "LastName", index: "LastName", width: 40, align: "left", sortable: true, formatter: 'showlink', formatoptions: { baseLinkUrl: 'javascript:', showAction: "Link('", addParam: "');" } },
                            { name: "DateofBirth", index: "DateofBirth", width: 40, align: "left", formatter: 'date', sorttype: "date", sortable: true },
                            { name: "DateofVisit", index: "DateofVisit", width: 40, align: "left", formatter: 'date', sorttype: "date", sortable: true },
                            { name: "PageType", index: "PageType", width: 40, align: "left", sortable: true },
                            { name: "InsuranceID", index: "InsuranceID", width: 50, align: "left", sortable: true },
                            { name: "Clinician", index: "Clinician", width: 50, align: "left", sortable: true },
                            { name: "ProcedureCode", index: "ProcedureCode", width: 50, align: "left", sortable: true },
                            { name: "CodeFee", index: "CodeFee", width: 50, align: "left", sortable: true }],

                    // Grid total width and height
                    multiselect: true,
                    rowNum: 20,
                    rowList: [5, 10, 15, 20],
                    width: 900,
                    height: "100%",
                    // Paging
                    pager: $("#pager1"),
                    viewrecords: true,


                    // Default sorting
                    //sortname: "FirstName",
                    sortorder: "asc",
                    sortable: true,
                    loadonce: true,
                    hidegrid: false,
                    // Grid caption
                    caption: "Reports List"
                }).navGrid("#pager1", { refresh: false, excel: true, add: false, edit: false, del: false }, {}, // settings for edit
                                                                                              {}, // settings for add
                                                                                              {}, // settings for delete
                                                                                              { sopt: ["cn"] } // Search options. Some options can be set on column level
                    ).jqGrid('navButtonAdd', '#pager1', {
                        caption: "Export to Excel",
                        buttonicon: "ui-icon-bookmark",
                        onClickButton: genGraph,
                        position: "last"
                    });
            }

        });

1 个答案:

答案 0 :(得分:1)

您的数据可能存在问题。您使用key: true作为列ID。这意味着jqGrid将使用id列中的值为每行(id元素的<tr>)分配ID属性的值。如果您在ID列中具有相同的值,而不是提供唯一值,则您的行为与您在问题中描述的行为完全相同。如果jqGrid需要选择或取消选择一行,那么它将按id搜索行。它会找到 ID为的第一行,如果其中一行的ID更多。因此,在许多情况下,它将选择/取消选择网格中的第一行。