PDA

View Full Version : Model Names do not allow spaces



dgherrig
31 Jul 2012, 6:28 AM
Hi,

The dataIndex names in my view have spaces in them, for example " Manager Class". However, when adding name to the Model it does not allow a name with spaces in it. Thus, after I deploy, I have to manually change the model names to match the dataIndex in the view and then everything works fine.

Is this a bug or is there a work-around for this probem.

Thanks Much for any help with this.

ssamayoa
31 Jul 2012, 7:42 AM
Very rare use case for naming fields (dataIndex).

I guess your server code is in MS technology 'cause MS is the only one I saw encourages developers to use spaces in database field names.

I don't think is a bug but a feature since 99.9% of the developers I know don't use spaces in identifiers. Just change your server code to send field names without spaces: "ManagerClass" or "Manager_Class" instead of "Manager Class".

Regards.

echobloom
27 Jan 2014, 2:33 PM
Super late on this, but if anybody has the same problem, the original answer here isn't correct. You can have models with spaces in the returned JSON, you just can't have spaces in the actual field name in the model. Example:



JSON:
{
"fieldMasterCategory": {
"Some Crazy Category Name ^&*": 42
},
}

Field definition in your model:
{
name: 'someFieldName',
type: 'string',
mapping: 'fieldMasterCategory',
convert : function(val, record) {
return val['Some Crazy Category Name ^&*'];
}
},