2

我正在尝试使用 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>'
        }
    });

我的键映射:

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”。当我按住任一键时,它们甚至都没有注册。

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

4

0 回答 0