2

I need to scroll to a form field (a displayfield actually) automatically. Since the field is dynamic, sometimes it is already shown in the rendered area of page, sometimes it is not.

How can I do this using ExtJS 4.x?

2 Answers 2

1

Use focus() on the desired displayfield :

<yourDisplayField>.focus();
Sign up to request clarification or add additional context in comments.

Comments

0

Use scrollTo function of Ext dom element. Reference

scrollTo( side, value, [animate] ) -> Scrolls this element the specified scroll point.

Parameters

  • side : String (Either "left" for scrollLeft values or "top" for scrollTop values.)
  • value : Number(The new scroll value)
  • animate : Boolean/Object (optional) (true for the default animation or a standard Element animation config object)

Add following lines of code to the form panel.

 listeners:{
        afterrender: function(){            
            this.body.el.scrollTo('top',200,true);
        }
    },

8 Comments

have already tried it; did not work for me. here is the sample code snippet: field.getEl().scrollTo('top', 200, true);
You have to call the scrollTo function of dom element of the container. Something like this - field.up('panel').scrollTo('top',200,true);
still did not work; the container is a formpanel. form.getEl().scrollTo('top',200,true); tried with various value parameter
Talha, I have added code. I think the scroll should be applied to the body element. Hope it helps.
And I think if you know the height used for each item in the form-panel, you can easily find the position of the required displayfield.
|

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.