簡體   English   中英

從extjs 4的手風琴和網格中獲取價值

[英]get value from accordion and grid in extjs 4

我想針對網格值的參數制作pdf報告。 我希望手風琴標題的年份為參數編號1,月份名稱為參數編號2.但是我無法做到。 任何人都可以幫我這個。 這是我的代碼如下:

Ext.define('Ext4Example.view.attendence.Timeperiod' ,{
    extend: 'Ext.form.Panel',
    alias : 'widget.timeperiod',
    id: 'timeperiod',
    region: 'west',
    border: true,
    width: 150,
    height:395,
    split: true,
    defaults: {
        // applied to each contained panel
        //bodyStyle: 'padding:15px'
    },
    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},
                { menuDisabled    : true,
                    sortable        : false,
                    xtype           : 'actioncolumn',
                    width           : 24,
                    items           : [{
                            icon        : "${resource(dir: 'images', file: 'PDF01001.png')}",
                            hide        : true,
                            tooltip     : 'Print PDF Report of this Month?',
                            handler     : function(record) {
                                          alert(record.data.month)
                            }
                        }]
                }
            ],
            listeners:{
                selectionchange:function(model, records ) {
                    var store = Ext.data.StoreManager.lookup('Attendences');
                    var record = records[0];
                    store.load({
                        filters: [
                            {property:'month', value:record.data.id},
                            {property:'year', value:record.data.year}
                        ]          
                    });                    
                }
            },
            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,
                ident: 'accordion-panel',
                items: me.mpanel(year)              
            });
        }
        return maccord;
    }
});

月份和年份都在您的記錄中。 你不需要從手風琴冠軍中獲得一年。 你的問題是,記錄不是處理程序中的第一個參數:

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.column.Action-cfg-handler

items: [{
   icon: 'test',
   tooltip: 'Print PDF Report of this Month?',
   scope: this,
   handler: function(view, rowIndex, colIndex, item, e, record) {
        alert(record.data.month + "/" + record.data.year);
   }
}]

你可以看看: http//jsfiddle.net/AMx6r/1279/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM