0

我有一个显示一年中月份的手风琴。现在我想在手风琴标题右侧添加一个 pdf 图标作为操作列,它将打印当年的所有记录。但我做不到。任何人都可以帮我解决这个问题。下面是我的代码:

Ext.define('Ext4Example.view.attendence.Timeperiod', {
    extend: 'Ext.form.Panel',
    alias: 'widget.timeperiod',
    id: 'timeperiod',
    region: 'west',
    border: true,
    width: 150,
    height: 396,
    split: true,
    layout: {
        // layout-specific configs go here
        type: 'accordion',
        titleCollapse: true,
        animate: true,
        activeOnTop: true,
        hideCollapseTool: true
    },
    initComponent: function () {
        var me = this;
        me.items = me.maccord();
        me.callParent(arguments);
    },
    mstore: function (year) {
        var data = [
            [1, year, 'January'],
            [2, year, 'February'],
            [3, year, 'March'],
            [4, year, 'April'],
            [5, year, 'May'],
            [6, year, 'June'],
            [7, year, 'July'],
            [8, year, 'August'],
            [9, year, 'September'],
            [10, year, 'October'],
            [11, year, 'November'],
            [12, year, 'December']
        ];
        var store = Ext.create('Ext.data.ArrayStore', {
            storeId: 'mstore',
            fields: [{
                name: 'id',
                type: 'int'
            }, {
                name: 'year',
                type: 'int'
            }, {
                name: 'month',
                type: 'string'
            }],
            data: data
        });
        return store;
    },
    mpanel: function (year) {
        var me = this,
            mpanel = new Ext.grid.Panel({
                border: false,
                viewConfig: {
                    stripeRows: true
                },
                hideHeaders: true,
                columns: [{
                    text: 'month',
                    dataIndex: 'month',
                    flex: 1]
                }],
            store: me.mstore(year),
            width: 150
            });
    return mpanel;
},
maccord: function () {
    var year = $ {
        (new Date()).format('yyyy')
    },
    limit = year - 5,
        me = this,
        maccord = [];
    for (year; year > limit; year--) {
        maccord.push({
            title: 'Year ' + year + {
                menuDisabled: true,
                sortable: false,
                xtype: 'actioncolumn',
                align: 'right',
                flex: 1,
                width: 22,
                items: [{
                    icon: "${resource(dir: 'images', file: 'PDF01001.png')}",
                    hide: true,
                    tooltip: 'Print Report of this Month?',
                    handler: function (grid, rowIndex, colIndex) {
                        alert('Printing');
                    }
                }]
            },
            ident: 'accordion-panel',
            items: me.mpanel(year)
        });
    }
    return maccord;
}
});
4

1 回答 1

3

绝对你尝试做的事情是行不通的。据我所见,您尝试通过将 Grid 连接到标题来将其添加到标题中。您可以做的是header为每个手风琴项目提供配置。在该标题中,您可以放置​​组件,但它们将显示在标题之前。另一种方法是处理afterrender事件,然后在标题中添加一些内容。

示例:http: //jsfiddle.net/HTMBy/2/

于 2012-12-05T09:10:03.497 回答