jqGrid 自定义 无数据提示信息

来源:互联网 发布:淘宝客服遇到的问题 编辑:程序博客网 时间:2024/06/05 23:44

当后台json返回数据为空时,jqGrid默认的“无数据显示”提示信息在右下角,不是很明显!

将提醒修改为如下效果:



网上搜索给出的方法都是需要在loadComplete事件中处理:

loadComplete:function(){var rowNum = $("#gridTable").jqGrid('getGridParam','records');if(rowNum < 1){if($("#emptyRecords").html() == null){$("#gridTable").parent().append('<div id="emptyRecords" style="width:100%; height:200px;  text-align:center;">'+'<div style="width:220px; height:100px; padding-top:40px; clear:both; margin:0 auto ;">'+'<img src="${ctx}/img/sjpic.jpg" width="206" height="44">'+'</div></div>');}$("#emptyRecords").show();}else{$("#emptyRecords").hide();}}

这就需要在每一个创建jqGrid的页面加入此事件处理代码,觉得太麻烦,也不便于以后更改,所以我修改了jqGrid源码:

我引用了以下两个js文件:


1、先将grid.locale-cn.js文件中默认的提示信息“emptyrecords”字段修改为空“”,使右下角不再显示提醒信息;



2、在jquery.jqGrid.min.js文件中相应处理代码替换为以下内容:



if (b.p.viewrecords)if (b.p.reccount === 0){if($("#" + b.p.id + "_norecords").html() == null){$("#" + b.p.id).parent().append('<div id="'+ b.p.id +'_norecords" style="width:100%; height:200px;  text-align:center;">'+'<div style="width:220px; height:100px; padding-top:40px; clear:both; margin:0 auto ;">'+'<img src="/js/jqGrid/themes/redmond/images/sjpic.jpg" width="206" height="44">'+'</div></div>');}$("#" + b.p.id + "_norecords").show();//a(".ui-paging-info", O).html(//b.p.emptyrecords);}else {$("#" + b.p.id + "_norecords").hide();P = D + 1;W = b.p.records;if (a.fmatter) {P = a.fmatter.util.NumberFormat(P, J);I = a.fmatter.util.NumberFormat(I, J);W = a.fmatter.util.NumberFormat(W, J)}a(".ui-paging-info", O).html(a.jgrid.format(b.p.recordtext,P, I, W))}

0 0
原创粉丝点击