Extjs editor 设置默认值

匿名 (未验证) 提交于 2019-12-02 23:56:01

一、前言

  Ext js 给 editor 设置默认值用 value 无效,在 Model 中添加 defaultValue 即可。

二、实例

view:

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:

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:

Ext.define('xxxx.model.ParamTemplateDto', {     extend: 'xxxx.common.model.BaseModel',        fields: [         { name: 'precision', type: 'number' ,defaultValue: 4},     ],     validators: {         precision: [             { type: 'presence', allowEmpty: false }         ]     } });

截图:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!