Grails和Extjs整合中的类型转换汇总
效果:
string 无需转换 string inList {fieldLabel: '${cgDomainProperties.string2.chinese}',name: 'string2',xtype: 'combo',store: new Ext.data.SimpleStore({ fields:['values'], data:[['选择1'],['选择2'],['选择3']]}), emptyText:'请选择${cgDomainProperties.string2.chinese}',mode: 'local', triggerAction: 'all', valueField: 'values', displayField: 'values'}, DateForm:{fieldLabel: '${cgDomainProperties.date1.chinese}',name: 'date1',xtype:'datefield',format:'Y-m-d'},
Controller: book.date1=(new java.text.SimpleDateFormat("yyyy-MM-dd")).parse(params.date1)
同时将:Config.groovy中添加grails.converters.json.date= 'javascript' intForm:{fieldLabel: '${cgDomainProperties.ingeger1.chinese}',name: 'ingeger1',xtype:'numberfield'},
Controller: book.ingeger1=params.ingeger1.toInteger() floatForm:{fieldLabel: '${cgDomainProperties.float1.chinese}',name: 'float1',xtype:'numberfield',allowDecimals:true},
Controller: book.float1=params.float1.toFloat() booleanForm: {boxLabel: '${cgDomainProperties.boolean1.chinese}',name: 'boolean1',xtype:'checkbox'}
book.boolean1=params.boolean1?true:false