Grails和Extjs整合中的类型转换汇总

效果:

Grails和Extjs整合中的类型转换汇总_第1张图片


  • 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'},
  • Date
  • Form:{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'
  • int
  • Form:{fieldLabel: '${cgDomainProperties.ingeger1.chinese}',name: 'ingeger1',xtype:'numberfield'},
        Controller: book.ingeger1=params.ingeger1.toInteger()
  • float
  • Form:{fieldLabel: '${cgDomainProperties.float1.chinese}',name: 'float1',xtype:'numberfield',allowDecimals:true},
        Controller: book.float1=params.float1.toFloat()
  • boolean
  • Form: {boxLabel: '${cgDomainProperties.boolean1.chinese}',name: 'boolean1',xtype:'checkbox'}
        book.boolean1=params.boolean1?true:false

你可能感兴趣的:(json,ext,ITeye,grails,groovy)