JQGRID显示空白而不是Null [英] JQGRID show blank instead of Null
问题描述
Am使用JQGrid
并从数据库中获取Null并显示在网格中.我可以更改查询以返回空白值.
Am using JQGrid
and am getting Null displayed in the grid as it comes from DB. I can change the query to return Blank value.
但是我尝试使用JQGrid进行处理.我如何replace null by blank values
在网格中.
But am try to handle using JQGrid. How do i replace null by blank values
in Grid.
我不想向用户显示NULL而是显示空白.
I don want to show NULL to users instead show blank.
我如何在JQGrid中实现这一目标?
How do i achieve this in JQGrid ?
谢谢
推荐答案
最好在服务器端进行处理,但是如果要在jqGrid中进行操作,则可以使用,所以我处理了两种情况):
It's probably best that you handle this server-side, but if you want to do it in jqGrid, you could use a custom formatter that converts null to the empty string. (I'm not sure if you are actually getting back the value null
or the String "NULL"
, so I handled both cases):
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
}, ...],
....
}
这篇关于JQGRID显示空白而不是Null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!