我正在使用JQGrid并且在网格中显示Null,因为它来自DB.我可以更改查询以返回空值.
但我尝试使用JQGrid处理.我如何replace null by blank values在网格中.
我不想向用户显示NULL而是显示空白.
我如何在JQGrid中实现这一目标?
谢谢
处理这个服务器端可能是最好的,但是如果你想在jqGrid中执行它,你可以使用一个自定义格式化程序将null转换为空字符串.(我不确定你是否真的收回了值null或字符串"NULL",所以我处理了两种情况):
var nullFormatter = function(cellvalue, options, rowObject) {
if(cellvalue === undefined || isNull(cellvalue) || cellvalue === 'NULL') {
cellvalue = '';
}
return cellvalue;
}
$("#myGridContainer").jqGrid({
....
colModel: [{
label: 'Name',
name:'name',
index:'name',
formatter:nullFormatter
}, {
label: 'Next Column',
name:'nextCol',
index:'nextCol',
formatter: nullFormatter
}, ...],
....
}
Run Code Online (Sandbox Code Playgroud)