简体   繁体   English

extjs4网格按功能分组

[英]extjs4 grid grouped with function

Ext.define('record.SecurityCase', {
            extend : 'Ext.data.Model',
            fields : [{
                        name : 'id',
                        type : 'string',
                        persist : false
                    }, {
                        name : 'takeplaceTime',
                        type : 'date',
                        persist : true
                    },  {
                        name : 'brief',
                        type : 'string',
                        persist : true
                    }],
                    groupField: 'takeplaceTime' 
});

A grid with store used model above.And I want it to be grouped with 'takeplaceTime'.for example: 上面有商店使用模型的网格,我希望将其与'takeplaceTime'分组,例如:

obj.takeplaceTime='2013-10-01';obj2.takeplaceTime='2013-04-01';obj3.takeplaceTime='2013-12-01';obj4.takeplaceTime='2012-12-01';

obj ; obj ; obj2 ; obj2 ; obj3 are one group as its year is 2013. obj4 will be another ,year 2012. obj3是一组,因为其年份是obj4将是另一组,即2012年。

Is there a groupRenderFunction to handle this? 有一个groupRenderFunction来处理吗?

You can define calculated property in Model for grouping. 您可以在Model定义计算的属性以进行分组。 Example: 例:

Ext.define('Model1', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'name',  type: 'string'},
        {name: 'seniority',  type: 'string'},
        {name: 'department',  type: 'string'},
        {name: 'group', type: 'string', convert: function(value, record) {
            return record.get('name').substr(0, 1); // first letter of name
        } }
    ]
});

Working sample in Ext JS 4.2: http://jsfiddle.net/BmVeg/1/ Ext JS 4.2中的工作示例: http : //jsfiddle.net/BmVeg/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM