I am working with ExtJS4 and looking for a way to implement "Go to top" functionality.
i.e. On the click of "top" button, the view should scroll back to the top of the component. How can I achieve this in ExtJS?
I am working with ExtJS4 and looking for a way to implement "Go to top" functionality.
i.e. On the click of "top" button, the view should scroll back to the top of the component. How can I achieve this in ExtJS?
In addition to rixo's answer (which would be the easiest way for scrolling to the absolute top) I want to mention that there is also a implementation on component level (scrollBy) which can be handy if you don't have to scroll the whole window.
Update
I must confess I never used scrollBy
myself so if it don't work out for you (the linked API should provide you with all infomration) I recommend you to use scrollTo() instead. Here's a working JSFiddle
Use it on Panel like
panel.getEl().scrollTo('Top', 0, true);
// or
panel.body.scrollTo('Top', 0, true); // this property is protected
// or
panel.getTargetEl().scrollTo('Top', 0, true); // this method is private and may be changed
and on a Treepanel or Gridpanel like
panel.getView().getEl().scrollTo('Top', 0, true);
body
Demo instead of getEl()
or the private method getTargetEl()
–
Froth © 2022 - 2024 — McMap. All rights reserved.