talha06
talha06

Reputation: 6466

ExtJS - How to automatically scroll to a form field?

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?

Upvotes: 2

Views: 2702

Answers (2)

Ankit Chaudhary
Ankit Chaudhary

Reputation: 4089

Use focus() on the desired displayfield :

<yourDisplayField>.focus();

Upvotes: 1

Gilsha
Gilsha

Reputation: 14591

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);
        }
    },

Upvotes: 0

Related Questions