1

I have a long form with comboboxes and buttons that add element to the form. Every time combobox's value gets upldated or elements get added, it scrolls up to the top of the form. I want the scrollbar to retain its position. I tried saving current scroll position by doing

     this.myForm.getScrollPosition();

But I get getScrollPosition is not a function error.

Any help on this?

3
  • why does your form scroll up to the top when you update a combo box? Mine doesn't. Commented Jul 24, 2013 at 16:19
  • Hi Dbrin, it's not just the combobox, even when I add a record to a grid inside the form, after adding, it goes on the top. For now I'd just like to save the current scroll position. How can I do that? Commented Jul 24, 2013 at 16:34
  • grid issue can be controlled there is a property for grids for that, i am not sure why it would affect your form though. See this answer here: stackoverflow.com/questions/13088506/… Commented Jul 24, 2013 at 17:31

1 Answer 1

4

If you are using extjs there is a way to manipulate the scroll using the Ext.dom.Element class, each component in Extjs inherits from it, then if you add a new component that modifies the height or width of your form, you can first get the height and width of that component using:

var newcompwidth = comboboxexample.getWidth();
var newcompheight = comboboxeample.getHeight();

Later you can modify the scroll value using scrollTo method like this:

myformcontainer.getEl().scrollTo('Top',myformcontainer.getEl().getScroll().top - newcompheight);

myformcontainer.getEl().scrollTo('Top',myformcontainer.getEl().getScroll().left - newcompwidth);

there are other methods like scrollBy or scroll but I didn't test it yet, I guess this will help you.

the docs: http://docs.sencha.com/extjs/4.1.0/#!/api/Ext.dom.Element

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.