jqGrid--加载事件loadComplete_gridComplete_ondblClickRow

gridComplete

gridComplete 每次加载完数据或者jqGrid中的数据变动都会加载一次里面的函数,
如果addRowData写在这里面则会无限循环执行里面的函数


loadComplete

loadComplete jqGrid加载完毕之后执行里面的函数,
jqGrid中的数据变动不会执行loadComplete中的代码


html代码:

<div class="col-xs-12 my-grid">
            <table id="listgrid"></table>
            <div id="pager">
                <div class="pager-left">
                    <div>
                            sum:<span id="sum"></span>
                    </div>
                </div>
            </div>
        </div>

js代码:

                loadComplete:function(xhr){
                    var sum=xhr.sum;
                    $("#sum").html(sum);
                },
gridComplete: function () {
                    ...
                     }

=====================================================

jqGrid 加载完jqGrid之后可以执行函数的方法

           gridComplete: function() {
                  jQuery('#first_gridpager').html("首页 ");
                  jQuery('#prev_gridpager').html("上一页");
                  jQuery('#next_gridpager').html("下一页");
                  jQuery('#last_gridpager').html(" 尾页");
                  //$("#mygrid").footerData("set",{item_danjia:"合计",items_count:itemsTotal});
                  $('#modalList').closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'hidden' });
              },
              loadComplete: function() {
                                    // 库存详情列表合计
                  var actualAmount = ${pd.actualAmount};
                  var priceAmount = ${pd.priceAmount};
                  var dataRow = {
kaidan_date:'',sup_name:'',pur_order_no:'',inv_actual:actualAmount,pur_price:priceAmount,price_total:'',caozuo:'',parts_id:'',sup_id:'',parts_name:''
                  };
                 $("#mygrid").jqGrid("addRowData","合计",dataRow, "last"); 
              }

=====================================================

事件
ondblClickRow

参数
rowid,iRow,iCol,e

备注
双击行时触发。
rowid:当前行id;iRow:当前行索引位置;iCol:当前单元格位置索引;e:event对象

$("#jobsGrid").jqGrid({
        url:'../job_controller',
        datatype: 'JSON',
        mtype: 'POST',
        pager: jQuery('#jobsGridPager'),
        colNames:['Job #','Project','City', 'Rep', 'Status', 'Customer', 'Cust PO #', 'Rep. #'],
        colModel :[
            {name:'jobNumber', index:'jobNumber', align:'left', width:50, editable:true,hidden:false, edittype:'text',
                    editoptions:{size:30,readonly:true},editrules:{edithidden:false,required:false}},
            {name:'description', index:'description', align:'left', width:150,hidden:false, editable:true, 
                    editoptions:{size:20,readonly:false, alignText:'right'},editrules:{edithidden:true,required:true}},
            {name:'locationCity', index:'locationCity', align:'', width:90,hidden:false, editable:true,
                    editoptions:{size:20,readonly:false, alignText:'right'},editrules:{edithidden:true,required:true}},
            {name:'initials', index:'initials', align:'center', width:30,hidden:false, editable:true,
                    editoptions:{size:20,readonly:false, alignText:'right'},editrules:{edithidden:true,required:true}},
            {name:'jobStatus', index:'jobStatus', align:'center', width:60,hidden:false, editable:true,
                    editoptions:{size:20,readonly:false, alignText:'right'},editrules:{edithidden:true,required:true}},
            {name:'customerName', index:'customerName', align:'', width:150,hidden:false, editable:true, 
                    editoptions:{size:20,readonly:false, alignText:'right'},editrules:{edithidden:true,required:true}},
            {name:'customerPONumber', index:'customerPONumber', align:'center', width:90, hidden:false, editable:true, 
                    editoptions:{}, editrules:{edithidden:true,required:false}},
            {name:'code', index:'code', align:'center', width:40,hidden:false, editable:true,
                    editoptions:{size:20,readonly:false, alignText:'right'},editrules:{edithidden:true,required:true}}
        ],
        rowNum: 50, pgbuttons: true,    
        recordtext: '',
        rowList: [50, 100, 200, 500, 1000],
        viewrecords: true,
        pager: '#jobsGridPager',
        sortname: 'employeeId', sortorder: "asc", imgpath: 'themes/basic/images',   caption: 'Jobs',
        height:547, width: 1140,/*scrollOffset:0,*/ rownumbers:true, altRows: true, altclass:'myAltRowClass', rownumWidth: 45,
        ondblClickRow: function(rowId) {
            var rowData = jQuery(this).getRowData(rowId); 
            var jobNumber = rowData['jobNumber'];
            var jobName = "" + rowData['description'];
            var jobCustomer = rowData['customerName'];
            var jobStatus = rowData['jobStatus'];
            jobName = jobName.replace(/&/g, "``");
            jobName = jobName.replace(/#/, "__");
            var aQryStr = "jobNumber=" + jobNumber + "&jobName=" + jobName + "&jobCustomer=" + jobCustomer;
            console.log("./jobflow?token=view&" + aQryStr);
            document.location.href = "./jobflow?token=view&" + aQryStr;
        },
        jsonReader : {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false,
            cell: "cell",
            id: "id",
            userdata: "userdata"
        }
    }).navGrid('#jobsGridPager', add:false,edit:false,del:false,refresh:false,search:false}
    );
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页