在Ext JS中捕获长按或点击网格行的保持事件

时间:2018-05-01 08:51:28

标签: javascript extjs extjs3

我正在使用rowcontextmenu网格事件来显示右键单击的一些选项,这在桌面上运行正常。在iPad中,我希望在长按时实现相同的功能,但我在sencha docs中发现了任何此类事件。我已经尝试了jquery长按插件但无法实现它。 我使用的是Ext JS 3.4版本。请提供任何提示。

1 个答案:

答案 0 :(得分:1)

这些侦听器(至少)必须应用于Ext.grid.RowSelectionModel,以便这些事件在该特定范围内正确绑定。见blog article;还有更多的DOM事件类型需要考虑。您要查找的事件可以是tapholdlongpress(请参阅Safari文档以了解“处理事件”。

可以定义RowSelectionModel的事件:

new Ext.grid.GridPanel({

    /**
     * one has to instance the default row-selection model explicitly,
     * in order to be able to configure it's event listeners ...
    **/
    sm: new Ext.grid.RowSelectionModel({
        singleSelect: true,
        listeners: {

            taphold: 'rowcontextmenu'

        }
    })

});

还可以使用Ext.util.Observable来调试事件;这很方便,尤其是当使用过时的框架时,它已经支持了多远,这是一个相当可疑的框架。

// to intercept all events:
Ext.util.Observable.prototype.fireEvent = 
Ext.util.Observable.prototype.fireEvent.createInterceptor(function() {
    console.log(this.name);
    console.log(arguments);
    return true;
});

// to capture the events of a particular component:
Ext.util.Observable.capture(
    Ext.getCmp('my-grid-component'), function(event) {
        console.info(event);
    }
);

使用Ext.EventManager.addListener().on(),可以定义任何缺少的框架事件。