首页 > 解决方案 > 当全选单击时,Jqgrid 数据未保存在已编辑的行上

问题描述

我像这样使用 Jqgrid:

 $("#grdMain" + TabID).jqGrid({

        datatype: 'local',

        colNames: ['ID', 'LookupCode','LookupTitle'],
        colModel: [

                    { name: 'ID', index: 'ID', hidden: true, editable: true, dataType: "number" },
                    { name: 'LookupCode', index: 'LookupCode', hidden: true },
                    { name: 'LookupTitle', index: 'LookupTitle', width: 100 }],
        localReader: {
            repeatitems: false,

            cell: "",
            id: "ID"
        },

        scrollOffset: 20,
        rowNum: 20,
        rowList: [10, 20],
        sortorder: 'asc',
        viewrecords: true,
        autowidth: false,
        gridview: true,
        forceFit: false,
        shrinkToFit: false,
        multiselect: true,
        width: 1255,
        height: 340,
        editurl: 'clientArray',
        rowNum: 1000000,
        direction: 'rtl',
        caption: '',
        gridstate: 'hidden',
        rownumbers: true,
        loadError: ServiceFailed,
        onSelectRow: function (rowid, isSelected) {

            $(this).editRow(rowid, true);

            $("#" + rowid + "_LookupTitle", "#grdMain" + TabID).lookup();

        },
        beforeSelectRow: function (rowid, e) {

            return DetailGridUtility.SaveDetail($(this), rowid, LastID);
        }, onSelectAll: function (ids, status) {

        }

    });

假设网格上有 10 行,我选择了 2 个第一行,第二行处于编辑模式,我更改了 lookupTitle (并且行仍处于编辑模式),现在我单击“全选复选框”,然后更改为第二行不考虑编辑模式

我该如何解决这个错误?

selectAll之前有方法吗?(如果有,我可以为 SellectAll 保存更改)

标签: jqueryjqgrid

解决方案


我解决了。我找到了 selectAll 复选框标记并为 mousedown 事件编写了函数并在此方法上保存了网格。此事件调用之前复选标记所有行。我无法使用 Click 事件或 change 事件,因为这些事件在选中所有行后调用

$("#cb_grdMain" + TabID).mousedown(function () {

   //Save Grid 
    });

推荐阅读