//查询记录 var grid_selector = "#grid-table"; var page_seletor = "#jqGridPager"; $("#btnLook").click(function drawTable() { var startDate = $("#startDatePick").val(); var endDate = $("#endDataPick").val(); if (startDate == '' || endDate == '') { alert("起始日期或截止日期不能为空") return } //初始化表格 jQuery(grid_selector).jqGrid({ subGrid: false, subGridOptions: { plusicon: "ace-icon fa fa-plus center bigger-110 blue", minusicon: "ace-icon fa fa-minus center bigger-110 blue", openicon: "ace-icon fa fa-chevron-right center orange" }, url: '/stock/searchByCategory', caption: '品类销售查询', data: {}, postData: { 'startDate': startDate, 'endDate': endDate }, datatype: "json", mtype: "post", height: 1000, autowidth: true, colNames: ['品类', '销售数量', '销售金额', '毛利额', '毛利率', '客流量', '客单价'], colModel: [ {name: 'c_name', sortable: false, width: 100}, {name: 'saleCount', sortable: false}, {name: 'itemSumPrice', index: 'item_sale_date', sortable: false, width: 80}, {name: 'grossProfit', sortable: false, width: 80}, {name: 'grossProfitMargin', sortable: false, width: 100}, {name: 'saleSumPeople', sortable: false, width: 80}, {name: 'perUnitPrice', sortable: false, width: 80} ], viewrecords: true,//显示总记录数 rowNum: 20, rowList: [10, 20, 30], pager: page_selector, altRows: false, //设置caption居中 gridComplete: function () { $(grid_selector).closest("div.ui-jqgrid-view") .children("div.ui-jqgrid-titlebar") .css("text-align", "center") .children("span.ui-jqgrid-title") .css("float", "none"); } })