-
4 Dec 2012 8:40 AM #1
Answered: Suppress 0 In Grid Column
Answered: Suppress 0 In Grid Column
I have a db file that contains a 3 digit number field (no decimals). If this field is "empty", naturally the value is 0. When I display this field in a grid, it shows up as 0. Instead of displaying 0, I want the field to display as blank. If the value is 3, it should show 3 (not 003). How do I suppress a value of zero (and any leading zeros) in a grid column? I tried searching for this answer but came up empty.
-
Best Answer Posted by Alexander Bauer
You can specify a custom renderer on a column, i.e.:
Code:{ // ... renderer : function(value) { value = parseInt(value); return value === 0 ? "" : value; } }
-
4 Dec 2012 8:48 AM #2
You can specify a custom renderer on a column, i.e.:
Code:{ // ... renderer : function(value) { value = parseInt(value); return value === 0 ? "" : value; } }
-
4 Dec 2012 10:08 AM #3
Make sure you do parseInt(value, 10) so that it parses as a decimal.
-
4 Dec 2012 11:25 AM #4
Thanks for the replies.
I think I see how this works. I'm a little new to the syntax of value === 0 ? "" : value;
Once I added that renderer to my column, the cell is now showing NaN.
*EDIT* BAH! User error. This works like a charm!


Reply With Quote