【问题标题】:Scroll event on ExtJS Grid Panel?ExtJS 网格面板上的滚动事件?
【发布时间】:2017-09-08 23:59:54
【问题描述】:

我在 ExtJS 中有一个带有滚动条的网格面板。我试图检测用户何时一直向下滚动(这样他们就不能再移动栏了)。到目前为止,我有这个,它检测滚动发生的时间,但没有提供关于滚动条在哪里的信息(?)。

//bufferedGrid is a grid panel
this.randomGrid.getView().on('scroll', this.onRandomGridScroll, this);
.
.
.
onRandomGridScroll : function(e, t)
{
    console.log(e);
    console.log(t);

}

任何指针将不胜感激。

【问题讨论】:

  • 您将需要为缓冲网格覆盖 Ext.grid.plugin.BufferedRenderer 类的 onViewScroll()。
  • @Tejas1991 "bufferedGrid" 只是一个名字......它不是指插件
  • 您正在使用缓冲网格(分页网格)?因此,您将需要覆盖我所说的相同方法,或者需要为此网格绑定滚动事件...。您可以选择哪个选项?
  • @Tejas1991 这只是一个网格...我在问题中更改了名称...

标签: javascript extjs scroll dom-events


【解决方案1】:

在初始化时添加事件 渲染网格后,添加 mouseup 事件和 wheel down 事件。

'container #gridId':{ afterrender: this.addScrollEventListener }

addScrollEventListener: function(comp){
    comp.getTargetEl().on('mouseup', function(e, t) {
        var height = comp.getTargetEl().getHeight();
        if (height + t.scrollTop >= t.scrollHeight) {

        }
    });
    comp.getTargetEl().on('wheeldown', function(e, t) {
        var height = comp.getTargetEl().getHeight();
        if (height + t.scrollTop >= t.scrollHeight) {

        }
    });
}

【讨论】:

    【解决方案2】:

    您可以访问当前滚动条位置(实际上是滚动条的顶部)和最大滚动位置如下(适用于Firefox,但不适用于Chrome):

    onBufferedGridScroll : function(e, t)
        {
            var max = this.bufferedGrid.getView().el.dom.scrollTopMax;
            var current = this.bufferedGrid.getView().el.dom.scrollTop;
            if( current == max )
                alert('You have reached the bottom of the scroll !');
        }
    

    【讨论】:

      猜你喜欢
      • 2011-09-24
      • 2021-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-15
      • 2011-08-06
      • 1970-01-01
      • 2012-12-01
      相关资源
      最近更新 更多