当我在页脚上单击下一页时,选中并取消选中JQGrid而不是持久性的复选框

时间:2014-02-26 10:29:57

标签: jquery jqgrid

嗨Oleg / JqGrid成员

我已经看到了同样的问题,你已经为很多人修好了。如果你有时间,请帮忙。

我想维护页面到页面的复选框选择。

我使用MVC从JSon获取数据并渲染到Grid。请在下面找到我的代码。

组织拥有所有数据。

 function RenderGrid() {

                var mydata = organisations;
                $grid = $("#gridOrganisation");
                var cbColModel;

                $grid.jqGrid({
                    width: 1030,
                    height: 255,
                    datatype: 'local',
                    data: mydata,
                    colNames: ['Org_MID', 'P_MID', 'Candidate_Detail', 'CompanyName', 'StreetAddress', 'City', 'PostCode', 'Country', 'EmailDomain', 'VATNo', 'IsLinked', 'NotLinked'],
                    colModel: [
                                { name: 'Org_MatchCandidateID', index: 'Org_MatchCandidateID', sorttype: 'int', hidden: true, width: 60 },
                                { name: 'PredefinedMatchID', index: 'PredefinedMatchID', hidden: true, sorttype: 'int', width: 50 },
                                { name: 'Candidate_Detail', index: 'Candidate_Detail', sorttype: 'string', width: 100 },
                                { name: 'CompanyName', index: 'CompanyName', width: 150, sorttype: 'string', align: "left" },
                                { name: 'StreetAddress', index: 'StreetAddress', width: 150, sorttype: 'string', align: "left" },
                                { name: 'City', index: 'City', width: 75, sorttype: 'string', align: "left" },
                                { name: 'PostCode', index: 'PostCode', sorttype: 'string', width: 60 },
                                { name: 'Country', index: 'Country', sorttype: 'string', width: 60 },
                                { name: 'EmailDomain', index: 'EmailDomain', width: 100, sorttype: 'string', sortable: true },
                                { name: 'VATNo', index: 'VATNo', width: 50, sorttype: 'string' },
                                { name: 'Count_IsLinked', index: 'Count_IsLinked', sorttype: 'int', width: 50 },
                                { name: 'Count_NotLinked', index: 'Count_NotLinked', sorttype: 'int', width: 50 }
                    ],

                    rowNum: 15,
                    rowList: [15, 30, 45],
                    pager: '#pager5',
                    gridview: true,
                    rownumbers: true,
                    multiselect: true,
                    idsOfSelectedRows: [],
                    onSelectRow: function (id, isSelected) {

                        //var row = jQuery("#gridOrganisation").jqGrid('getGridParam', 'selrow');
                        var ret = jQuery("#gridOrganisation").jqGrid('getRowData', id);
                        //alert(ret.Org_MatchCandidateID);
                        id = ret.Org_MatchCandidateID;
                        var p = this.p, idsOfSelectedRows = p.idsOfSelectedRows, item = p.data[p._index[id]], i = $.inArray(id, idsOfSelectedRows);
                        item.cb = isSelected;

                        if (!isSelected && i >= 0) {
                            idsOfSelectedRows.splice(i, 1); // remove id from the list
                        } else if (i < 0) {
                            idsOfSelectedRows.push(id);
                            //alert(id);
                        }
                    },
                    loadComplete: function () {
                        var p = this.p, idsOfSelectedRows = p.idsOfSelectedRows, data = p.data, item, $this = $(this), index = p._index, rowid, i, selCount;
                        //alert(idsOfSelectedRows);
                        for (i = 0, selCount = idsOfSelectedRows.length; i < selCount; i++) {
                            rowid = idsOfSelectedRows[i];
                            item = data[index[rowid]];
                            if ('cb' in item && item.cb) {
                                $this.jqGrid('setSelection', rowid, false);
                            }
                        }
                    },


                    sortname: 'CompanyName',
                    viewrecords: true,
                    sortorder: "asc",
                    caption: "Organisations Data"

                }).navGrid("#pager5", { edit: false, add: false, del: false });

                $("#cb_" + $grid[0].id).hide();
                $("#jqgh_" + $grid[0].id + "_cb").addClass("ui-jqgrid-sortable");
                cbColModel = $grid.jqGrid('getxColProp', 'cb');
                cbColModel.sortable = true;
                cbColModel.sorttype = function (value, item) {
                    return 'cb' in item && item.cb ? 1 : 0;
                };


            }

            $('#divGridOrganisation').show();

        });

显然绑定到JQgrid很好,当我从页脚点击任何一个时,问题是复选框不是持久性的。例如:Page 1 - 2和2 - 3等。

以下是Html代码

 <table id="gridOrganisation" ></table>
      <div id="pager5"></div>

如果您需要什么,请告诉我。

0 个答案:

没有答案
相关问题