Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs scrolling a panel to a position

Tags:

extjs

Hi i have a panel and i want to scroll to a particular postiton in that panel how do i do it

var tabs= new Ext.Panel({
    id:id,      
    title:text,
    autoScroll:true,
    iconCls:'windowIcon',
    closable:true,
    closeAction:'hide'
});
like image 367
mayan Avatar asked May 11 '11 06:05

mayan


2 Answers

Set the scrollTop property of the panel's body to the number of pixels you want to scroll down:

// Scroll the body down by 100 pixels.
tabs.body.dom.scrollTop = 100;
like image 73
owlness Avatar answered Nov 15 '22 04:11

owlness


Another option is to use the function scrollTo() here,

http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.Element-method-scrollTo

e.g.

Ext.getCmp('graph_panel').body.scrollTo('left',250);  
Ext.getCmp('graph_panel').body.scrollTo('top',200); 

But scrollTo() function does not bound check to make sure the scroll is within this element's scrollable range whereas the scroll() function does, hence it is best to use the scroll() function.

e.g.

Ext.getCmp('graph_panel').body.scroll('left',300);
Ext.getCmp('graph_panel').body.scroll('bottom',300);
like image 23
Pratik Patel Avatar answered Nov 15 '22 05:11

Pratik Patel