Ext js 給 editor 設置默認值用 value 無效,在 Model 中添加 defaultValue 便可。json
view:ide
Ext.define('xxxx.view.ParamGrid', { extend: 'Ext.form.field.GridField', xtype: 'paramgrid', store: { type: 'esms.paramtemplatestore' }, initComponent: function () { this.columns = [{ xtype: 'numbercolumn', header: '精度', format: '0', dataIndex: 'precision', hideEditorInValueMode: true, editor: { xtype: 'numberfield', allowBlank: false } }]; this.callParent(arguments); } });
Store:this
Ext.define('xxxx.store.ParamTemplateStore', { extend: 'Ext.data.Store', alias: 'store.paramtemplatestore', model: 'xxx.model.ParamTemplateDto', proxy: { type: 'memory', reader: { type: 'json' } }, autoLoad: false, remoteSort: false, remoteFilter: false, remoteGroup: false });
Model:spa
Ext.define('xxxx.model.ParamTemplateDto', { extend: 'xxxx.common.model.BaseModel', fields: [ { name: 'precision', type: 'number' ,defaultValue: 4}, ], validators: { precision: [ { type: 'presence', allowEmpty: false } ] } });
截圖:code