vertical scrollbar in ExtJS GridPanel

半世苍凉 提交于 2020-01-14 07:15:15

问题


I'm working on a project where I have a single GridPanel on a page. The panel can display any number of rows and I have the autoHeight property set, which causes the GridPanel to expand to fit the number of rows. I now want a horizontal scrollbar because on some resolutions not all columns get displayed (and I cannot reduce the number of columns).

If I set the autoHeight I have no horizontal scrollbar, if I do not set it and set a fixed height I have a horizontal scrollbar but the GridPanel obviously does not fit the number of rows....

Is there anything I can do to fix this? I can't seem to find a property that would achieve the result I need.


回答1:


You will find that putting a parent container (Ext.panel.Panel or any container really) around your grid panel to be successful. If you hard code the height, width and layout (to 'fit') on the parent container, the child item (Ext.grid.Panel) will expand to fill the entire space available from it's parent container.

See pages 80 and 81 of Ext JS 4 Web Application Development Cookbook.

You can use the lazy instantiation notation for 'Ext.grid.Panel'. Meaning use 'grid' for your child container (item) xtype property.

Ext.create('Ext.panel.Panel', {
    title: 'parent container',
    width: 800,
    height: 600,
    layout: 'fit',
    items: {
        xtype: 'grid',
        title: 'child container',

        ... define your grid here 

    },
    renderTo: 'grand parent container'
});



回答2:


My thought would be to set autoScroll: true on the panel.Panel that contained the grid.




回答3:


This seems like an issue with your layout settings as opposed to the object properties.

Try setting the layout property of the parent container to 'fit'- can you also provide a code excerpt?




回答4:


As Ergo said, this is more likely a layout problem - the GridPanel is probably higher than the panel containing it, high enough not to need a scrollbar but not fully visible, obviously. Put the GridPanel into a container with a proper layout, i.e. border layout, fit layout or card layout. Getting layout managers right is generally one of the hardest part of ExtJS-Fu.




回答5:


adding

viewConfig = {
        scroll:false,
        style:{overflow: 'auto',overflowX: 'hidden'}
    }

sometimes causes a bug with displaying 2 scrollbars. To prevent it in my case I added a listener. And then works fine.

this.on('scrollershow',function(scroller,orientation,eOpts){
        if (orientation=='vertical'){
            scroller.hide();                
        }
},this);


来源:https://stackoverflow.com/questions/3817338/vertical-scrollbar-in-extjs-gridpanel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!