解决jqgrid中单元格编辑与自带多选冲突的问题

先定义变量数组存放多选的id

var idlist=[];

在jqgrid的onCellSelect事件书写逻辑

 onCellSelect: function (rowid, iCol, cellcontent, e) {
          var checkedState = $("#grid #jqg_grid_" + rowid).prop("checked");  //获取当前点击行是否选中
          if(iCol==0){
            checkedState=!checkedState;
            if (checkedState) {
              idlist.splice($.inArray(rowid,idlist),1);
              $("#grid #jqg_grid_" + rowid).prop("checked", true);//打钩,
              $("#grid #" + rowid).css({ "background": "#fff" });//样式
            } else {
              idlist.push(rowid);
              $("#grid #jqg_grid_" + rowid).prop("checked", false);
              $("#grid #" + rowid).css({ "background": "#f8ff94" });
            }
          }else{
             console.log(checkedState);
            if (checkedState) {
              idlist.splice($.inArray(rowid,idlist),1);
              $("#grid #jqg_grid_" + rowid).prop("checked", false);
              //$("#grid").jqGrid("setSelection", rowid, false);
               $("#grid #" + rowid).css({ "background": "#fff" });
            } else {
               idlist.push(rowid);
              $("#grid #jqg_grid_" + rowid).prop("checked", true);
              //$("#grid").jqGrid("setSelection", rowid, true);
              $("#grid #" + rowid).css({ "background": "#f8ff94" });
            }
           
          }
         // var select_rowid = $("#grid").jqGrid("getGridParam", "selarrrow");
          var select_rowid =idlist;//选中的ids
        //  var money = 0;
         // select_rowid.forEach(function (self, index) {
         //   var get_data_from_id = $("#grid").jqGrid("getRowData",self).invoice_price;
          //  money = money / 1 + get_data_from_id / 1;
         // });
          //$('#billAmount').val(money);
        
      },
      

 

posted @ 2021-11-10 14:36  zhang_you_wu  阅读(191)  评论(0编辑  收藏  举报