View Full Version : Change JSON read data from "" to '\u00a0'

24 Feb 2010, 10:51 AM
I'm reading in data using a JSON reader to display in a combobox, which is in a grid.

The incoming data has some fields that are blank: "".

I'd like my script to map "" to '\u00a0' and correctly enter that data into my combobox.

Some code:


var logReader = new Ext.data.JsonReader({
root: 'Data',
fields: [{
name: 'logName',
mapping: 'logName'
}, {
name: 'logLevel',
mapping: 'logLevel'

combo store:

var levelComboStore = new Ext.data.ArrayStore({
fields: ['logLevelComboValue', 'logLevelComboDisplay'],
data: [['', '\u00a0'], ['TRACE', 'TRACE'], ['DEBUG', 'DEBUG'], ['INFO', 'INFO'], ['WARN', 'WARN'], ['ERROR', 'ERROR'], ['FATAL', 'FATAL'], ['OFF', 'OFF']]


var levelCombo = new Ext.form.ComboBox({
store: levelComboStore,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
lazyRender: true,
typeAhead: true,
valueField: 'logLevelComboValue',
displayField: 'logLevelComboDisplay',
valueNotFoundText: 'Value Not Found'

24 Feb 2010, 11:43 AM
I would add a convert function to the field definition of your grid's store to change "" into \u00a0. see http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Field

24 Feb 2010, 12:26 PM
evanc, thanks I think this will work!

However, I'm new to extJS and JS in general and I'm not sure how to compare v to ''.

Here are my attempts, both of which haven't worked.

function blankToNBS(v, record){
return (v == '') ? '\u00a0' : v;

function blankToNBS(v, record){
return !v ? '\u00a0' : v;

Any help?


this is the JSON code:


24 Feb 2010, 4:02 PM
I assume that when you say '' you're indicating an invisible unicode string.

try doing something like

if (v.charCodeAt(0) == 118) {

I don't know what the charcode for '' is but you should be able to find it experimentally using firebug, if nothing else.