简体   繁体   English

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

[英]Capture long press or tap hold event of grid row in Ext JS

I am using rowcontextmenu event of grid to display some options on right click which is working fine on desktop. 我正在使用grid的rowcontextmenu事件在右键单击上显示一些选项,在桌面上运行良好。 In iPad i want to implement same functionality on long press but i dint found any such event in sencha docs. 我想在iPad上长按实现相同的功能,但是我在sencha docs中发现了任何此类事件。 I have tried jquery long press plugin but couldn't achieve it. 我尝试了jquery长按插件,但无法实现。 I am using Ext JS 3.4 version. 我正在使用Ext JS 3.4版本。 Any hints please. 有任何提示请。

these listeners (at least) have to be applied to the Ext.grid.RowSelectionModel , so that these events are being properly bound within that particular scope. 这些侦听器(至少)必须应用于Ext.grid.RowSelectionModel ,以便将这些事件正确绑定在该特定范围内。 see this blog article ; 看到这篇博客文章 ; there are a bunch more DOM event types to consider. 还有更多的DOM事件类型需要考虑。 the event you are looking for is either called taphold or longpress (see the Safari documentation for "Handling Events"). 你正在寻找要么称为事件tapholdlongpress (见Safari浏览器的“处理事件”的文档)。

the events of the RowSelectionModel can be defined alike: 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'

        }
    })

});

one can also use Ext.util.Observable to debug events; 也可以使用Ext.util.Observable来调试事件; this comes handy, especially when using a dated framework, where it is rather questionable, in how far the functionality was already supported. 这很方便,尤其是在使用过时的框架时(在该框架中已经支持该功能的地方相当可疑)。

// 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);
    }
);

with Ext.EventManager.addListener() or .on() , one can define just any missing framework events. 使用Ext.EventManager.addListener().on() ,可以仅定义任何缺少的框架事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM