jqGrid 导出方法json
问题:jqGrid 加载导出,出现一只加载报错;post
解决: url
jqGrid 其中有有个为Gird.csvExport();的方法,可直接导出表格的各列和其中的数据,code
附上一段码对象
<div style="width:1200px;overflow-x:auto"> <table id='transferList'></table> </div> ----------- var Gird = $("#transferList").jqGrid({ caption :'<div style=" width:100%;">'+ '<input class="gridExport goSearch" type="button" value="导出" style=" margin-right:5px;float:left;"/></div>', datatype: "local", mtype: 'post', height: '100%', width:'100%', colNames:['ID','地区'], prmNames: {page:"pageNo",rows:"pageSize"}, colModel:[ {name:'id',index:'id', width:100, key: true, hidden: true}, {name:'address',index:'address', width:130, align:"center" } ], rowNum:15, rowList:[15,30,50] });
这是数据表格基本内容,(还有属性没有设置);input
导出io
$(".gridExport").click(function() { // 下载列表 jQuery("#transferList").jqGrid('setGridParam', { datatype:'json', url :g_baseURL + '/sx/dataVaildation/dataValidationList?checkItems='+$("#checkItems").val()+'&showInfo='+ $("#showInfo").val() }).csvExport(); //validationListGird.csvExport();//这句也是能够直接导出的 });
其中 jQuery("#transferList").jqGrid('setGridParam', { }),是返回的jqGrid对象,直接调用csvExport()方法。table
注意到 数据表格 中没有url 这属性,没有这一属性,导出会失败,就会出现一直加载。 数据表格加上URL这一属性,能够导出,可是 想从这里带参进入controller,这个参数的值页面上得到不到,带进入的值会默认为标签的第一项(好比下拉框),function
那又如何解决呢,可采用以上方法 { }中设置参数 URL属性附上,带参进入。class
这时工做中遇到的问题,此刻作个记录,不正之处,望指正。