我正在使用网格的 rowcontextmenu 事件来显示右键单击的一些选项,这在桌面上运行良好。在 iPad 中,我想在长按时实现相同的功能,但我在 sencha 文档中没有找到任何此类事件。我尝试过jquery长按插件但无法实现。 我使用的是 Ext JS 3.4 版本。请任何提示。
最佳答案
这些监听器(至少)必须应用于 Ext.grid.RowSelectionModel ,以便这些事件被正确地绑定(bind)在该特定范围内。看到这个blog article ;还有更多 DOM 事件类型需要考虑。您正在查找的事件称为 taphold
或 longpress
(请参阅 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() ,可以定义任何缺失的框架事件。
关于javascript - Ext JS 捕获网格行的长按或点击按住事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50113710/