PDA

View Full Version : Checking if a grid have vertical scrollbar



webfriend13
20 Jun 2012, 8:27 PM
Hi All,

I am using ExtJs 4.1 framework. I want to check if a grid is having vertical scroll bar. Do we have any inbuilt property or method? If not, how can I check it ?

Thank you :)

sword-it
20 Jun 2012, 10:00 PM
HI!

you may try the following, it will give you scroll of your grid in current view.

By this , you can find easily your grid has scroll or not based on the factors/conditions applied by you.




Yourgrid.getEl().down('.x-grid-view').getScroll();

webfriend13
21 Jun 2012, 1:07 AM
Hi Srord-IT,

Thank you for quick reply. Using "Yourgrid.getEl().down('.x-grid-view').getScroll();" only returns top and left property.which tells you about the scoll position. It remains 0 , 0 when the scroll bars are not present & 0,0 when scroll bar are present and they remain at their default location. I dont think I can use this option to find out if vertical scroll bar is present for the grid or now.

Thank you.

sword-it
21 Jun 2012, 3:24 AM
Hi!

try this, it will work.




if (grid.view.getWidth() > parseFloat(grid.view.getEl().dom.children[0].style.width)) {
alert('scroll is present')
}

webfriend13
22 Jun 2012, 1:00 AM
HI Sword-It,

Thank you reply. Following code is working for me



if (grid.view.getWidth() < parseFloat(grid.view.getEl().dom.children[0].style.width)) {
alert('horizontal scroll is present');
} if (grid.view.getHeight() < parseFloat(grid.view.getEl().dom.children[0].scrollHeight)) {
alert('vertical scroll is present');
}