jqgrid常用方法总结

1.选中行数据

  var rowId =$(grid_selector).jqGrid("getGridParam", "selrow");
  var rowData = $(grid_selector).jqGrid("getRowData", rowId);

2.多选

   var ids =$(grid_selector).jqGrid("getGridParam","selarrrow");
    if (ids.length<=0){
        return alert("请选中后编辑");
    }
    var list=[];
    var activityId;
    for (var i = 0; i < ids.length; i++) {
        var statusStr=$(grid_selector).getCell(ids[i],"status");
        if (statusStr.indexOf("通过")!=-1){
            return alert("状态不可修改");
        }
        activityId=$(grid_selector).getCell(ids[i],"activityId");
        var userId=$(grid_selector).getCell(ids[i],"userId");
        var openId=$(grid_selector).getCell(ids[i],"openId");
        var formId=$(grid_selector).getCell(ids[i],"formId");
        var title=$(grid_selector).getCell(ids[i],"title");
        var startDate=$(grid_selector).getCell(ids[i],"startDate");
        var address=$(grid_selector).getCell(ids[i],"address");

        var strData=userId+"^"+openId+"^"+formId+"^"+title+"^"+startDate;
        list.push(strData);
    }

3.双击单元格时触发
实例:单元格编辑,回车提交保存

       ondblClickRow:function(rowid,iRow,iCol,e){
                    if (iCol==3){//第三列
                        $(grid_selector).setColProp('status',{editable:{value:false}});
                        $(grid_selector).editRow(rowid,true);
                    }
                }

4.动态改变列属性

  $(grid_selector).setColProp('ac',{formatter:function (cellVal, opts, rowObj) {
                  var value='';
                  if (rowObj.status ==2) {
                         value ='';
                         return value;
                     }
                 }
          });

你可能感兴趣的:(js)