extjs 枚举类型 使用方法

extjs | 2019-09-13 10:02:39

1.定义 extjs 枚举类型 枚举类代码:


Ext.define('Soims.model.application.ApplicationState', {
    statics: { // 关键
        Unknown: { value: 'Unknown', name: '未知类型' },
        Deleted: { value: 'Deleted', name: '已删除' },
        UnSubmit: { value: 'UnSubmit', name: '未提交' },
        Submit: { value: 'Submit', name: '已提交' }
    }
});


2.调用枚举类型:


Ext.define("Soims.view.application.ApplicationGrid", {
    extend: 'Ext.grid.Panel',
    requires: 'Soims.model.application.ApplicationState', // 引用文件
    alias: 'widget.applicationgrid',
    title: '申请书列表',
    closable: true,
    selType: 'rowmodel',
    initComponent: function () {
        this.columns = [
           {
               header: 'id',
               dataIndex: 'id',
               flex: 1,
               hidden: true
           }, {
               header: '申请状态',
               dataIndex: 'state',
               flex: 1,
               renderer: function (value) {
                   return Soims.model.application.ApplicationState[value].name; // key-value
               }
           }];
        this.callParent();
    }
});


登录后即可回复 登录 | 注册
    
关注编程学问公众号