如何使用分页工具栏在网格面板上获取KeyMap keydown事件

时间:2013-04-17 23:46:42

标签: extjs extjs4

我正在尝试使用pagingtoolbar在我的网格面板上运行keydown事件,这样当您按住向上或向下箭头键时,它会继续通过页面而无需停止或重复按键。此过程适用于keyup事件,但我还没有设法让它识别keydown事件。

我的代码是最新的:

网格:

trackGrid = new Ext.grid.GridPanel({
        layout: 'fit',
        autoSizeColumns:false,
        autoHeight:true,
        maxHeight:400,
        frame:true,
        trackMouseOver:true,
        selModel: Ext.create("Ext.selection.RowModel"),
        store: TrackPaged,
        columns:[
            {header: 'Time', width:55, sortable: true, dataIndex: 'time'},
            {header: 'Speed', width:50, sortable: true, dataIndex: 'speed', renderer: this.renderTrackSpeed},
            {header: 'Dirn', width:50, sortable:true, dataIndex: 'hdg', tooltip: 'Direction of travel'},
            {header: 'ECode', width:70, sortable:true, dataIndex: 'event', renderer: this.renderTrackEvent, tooltip: 'Event Code'},
            {header: 'Status', width:50, sortable:true, dataIndex: 'sts'},
            {header: 'id', width:50, sortable:true, dataIndex: 'lid', hidden: true}
        ],
        viewConfig:{
            forceFit:true,
            EnableRowBody:true,
            showPreview:false
        },
        bbar:trackPagedToolbar,
        footerCfg:{
            html:'<div id="track-info" class="grid-info"><p>No events to display</p></div>'
        }
    });

我的KeyMaps:

trackGrid.getEl().set({tabindex: "0"})

    trackGrid.getEl().addKeyMap({
        eventName: "keyup",
        binding: [{
            key: Ext.EventObject.ENTER,
            fn: function() {
                this.selectTrackMarkerInfo();
            }
        }, {
        key: [Ext.EventObject.RIGHT, Ext.EventObject.PAGE_DOWN],
        fn:  function(){ 
            trackPagedToolbar.moveNext();
                    trackGrid.getSelectionModel().select(0); 
        }
        },{
        key: [Ext.EventObject.LEFT, Ext.EventObject.PAGE_UP],
        fn: function(){ 
            trackPagedToolbar.movePrevious();
                    trackGrid.getSelectionModel().select(0);
        }
        }, {
            key: Ext.EventObject.HOME,
            fn: function() {
                trackPagedToolbar.moveFirst();
                    trackGrid.getSelectionModel().select(0);
            }
        }, {
            key: Ext.EventObject.END,
            fn: function() {
                trackPagedToolbar.moveLast();
                    trackGrid.getSelectionModel().select(TrackPaged.getCount()-1);
            }
        }]
    });

    trackGrid.getEl().addKeyMap({
        eventName: 'itemkeydown',
        binding: [{
        key: Ext.EventObject.DOWN,
        fn: function() {
            if (trackGrid.getSelectionModel().getSelection()[0].index % 14 == 13) {
                trackPagedToolbar.moveNext();
                trackGrid.getSelectionModel().select(0);
            }
        }
    }, {
        key: Ext.EventObject.UP,
        fn: function() {
            if (trackGrid.getSelectionModel().getSelection()[0] = 0) {
                trackPagedToolbar.movePrevious();
                trackGrid.getSelectionModel().select(13);
            }
        }
    }]
    });

从KeyMap上的文档中我没有尝试专门添加trackGrid的目标,并将事件更改为“itemkeydown”,“keydown”和“keypress”。当我按住任一键时,它们都没有注册。

有没有人对此事有任何见解?

0 个答案:

没有答案