//与html中参数ID 相对应
var brand_id = $("#brand_name").val();
var store_id = $("#store_name").val();
var business_type = $("#business_type").val();
//标题清空
$("#dataContent").empty();
//加载html
$("#dataContent").html('<table id="dataTable"></table><div id="dataPager"></div>');
//标题主体。。两种写法之一
$("#dataTable").jqGrid({
//发送ajax
url: 'mvc/getWisdom',mtype: "POST",//一般为post,get请求会有中文乱码问题
//请求参数
postData: {
store_id: store_id,
business_type:business_type
},
styleUI: 'Bootstrap',
//请求格式,也可这样写
1 data: JSON.stringify({}),
2 var condition = {
var brand_id = $("#brand_name").val();
var store_id = $("#store_name").val();
var business_type = $("#business_type").val()};
data: JSON.stringify(condition)
datatype: "json",
//Gird主体
colNames:['序号','品牌id','品牌','店铺id','店铺','业务类型','创建人','创建时间','备注','操作'],//列名colModel:[ //名称 ,索引,行宽,位置,是否隐藏,是否排序sortable:false,可后面写匿名hanshu
{name:'id',index:'id',width:20,align:"center",hidden:true},
{name:'brand_id',index:'brand_id',width:40,hidden:true},
{name:'brand_name',index:'brand_name',width:40,align:"left",hidden:true},
{name:'store_id',index:'store_id',width:40,hidden:true},
{name:'store_name',index:'store_name',width:40,align:"left",hidden:true},
{name:'business_type',index:'business_type',width:30,align:"left"},
{name:'creat_man',index:'creat_man',width:40,align:"left"},
{name:'creat_time',index:'creat_time',width:20, align:"right"},
{name:'remark',index:'remark',width:40, sortable:false,align:"left"},
{name:'edit',index:'id',width:30,align:"center",sortable:false,
//匿名函数,拼接加“&”,否则前台报null
formatter:function(cellvalue, options, rowObject,lookfor){
return "<a href='javascript:;' data-title='xxxx明细' data-url='showad/wisdomDetailsShow.html? wisdom_id="+rowObject.id+"&brand_name="+rowObject.brand_name+"&store_name="+rowObject.store_name+"&business_type="+rowObject.business_type +"' name='detailsButton' class='text-success'>明细</a>"+ "|"+"<a href='javascript:;' name='delButton' class='text-success' wisdomId='"+rowObject.id+"'>删除</a>";
}}
],
viewrecords: true,
rowNum: 15,//每页多少条
pager: "#dataPager",//分页
rowList : [15,30,50],//选择展现条数
sortable : true,//是否排序
sortname : "creat_time",//按那个字段排序
sortorder : "desc",//排序升序还是降序
height:"auto",//高度适应
autowidth: true,
shrinkToFit: true,
rownumbers:true,
//回调函数
gridComplete:function(){$("a[name='delButton']").click(function(){
wisdomImport.delForm(this);
});
$("a[name='detailsButton']").on("click",window.parent.loadIframe);
//隐藏水平滚动条 chrome里默认的table计算值会多一个像素,导致出现滚动条
$("#dataTable").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
}
}).navGrid("#dataPager",{
//下角展示刷新等
add:false,edit:false,
del:false,
search:false
});
}