简体   繁体   English

如何滚动到Ext JS 3.4网格的底部?

[英]How to scroll to bottom in the Ext JS 3.4 grid?

i have a grid panel (with Ext.ux.grid.RowEditor panel inside) and I want to scroll to the bottom (near the bottom my Ext.ux.grid.RowEditor is not shown completely), 我有一个网格面板(里面有Ext.ux.grid.RowEditor面板),我想滚动到底部(在底部附近,我的Ext.ux.grid.RowEditor没有完整显示),

this piece of code is not working: 这段代码不起作用:

this.MyGrid.getView().on('scrollToBottom', function(){
        var inputEl = this.MyGrid.el.dom;
        inputEl.scrollTop = inputEl.scrollHeight;
    }, this);

..... .....

and then when pressing save button i fire event: 然后按下保存按钮时,我会触发事件:

this.MyGrid.getView().fireEvent('scrollToBottom',this);

any ideas why it's not scrolling? 任何想法,为什么它不滚动? thanks! 谢谢!

The .on() function is used to set up a listener function for an event, not add a custom event. .on()函数用于为事件设置侦听器功能,而不是添加自定义事件。 Similarly, the .fireEvent() function is used to trigger an event on an object. 同样, .fireEvent()函数用于触发对象上的事件。 AFAIK you can't define you're own events, and there is no "scrollToBottom" event in ExtJs. 不能定义您自己的事件,而且ExtJs中没有“ scrollToBottom”事件。

What you'll want to do is define your scrollToBottom code as a function, and then call this from your save button click handler 您要做的就是将您的scrollToBottom代码定义为一个函数,然后从保存按钮的点击处理程序中调用它

Please try to add an event to your grid using addEvent method(using init) and then add the event as the listener to your grid. 请尝试使用addEvent方法(使用init)将事件添加到网格中,然后将事件作为侦听器添加到网格中。 Fire the event whenever necessary(In your case when user hits the save button.) using fireEvent method and subscribe it in your listener. 必要时使用fireEvent方法触发事件(在用户单击保存按钮的情况下),然后在侦听器中订阅它。

Example code looks like the below(You have to add this event and then fire it.) Adding the event in the init component looks like below(in the below this refers to grid scope) 示例代码如下所示(您必须添加此事件,然后将其触发。)将事件添加到init组件中如下所示(在下面,这是指网格范围)

this.addEvents('SCROLL_TO_BOTTOM');

You have to subscribe the event and set your scroll height for your grid.Add the below listener to your grid. 您必须订阅该事件并设置网格的滚动高度。将以下侦听器添加到网格中。

listeners: {
         'SCROLL_TO_BOTTOM': this.handleScroll,
         scope: this
         }

Function for handling the scroll 处理滚动的功能

 handleScroll:function(){   
           var inputEl = this.MyGrid.el.dom;
           inputEl.scrollTop = inputEl.scrollHeight;
         }

Hope this helps you... 希望这对您有帮助...

i have found the solution! 我找到了解决方案! no additional events and listeners, just 没有其他事件和听众,只是

var inputEl = this.myGrid.getView().scroller.dom;
inputEl.scrollTop = inputEl.scrollHeight;

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

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