2

I've been unable to add Scroll Bars to two views I have displaying with Ext. Each View is an extension of a base view, and the base has autoScroll: true. I've verified that the elements are properly assigned an overflow: auto property.

I've done some searching around and found this question and after applying it's solution (even though I wasn't using this 'vbox' layout) it didn't solve my problem.

Here is the base view:

Ext.define('Our.extensions.baseList', {
    extend: 'Ext.view.View',
    itemSelector: 'div.postContainer',
    autoScroll: true,

    initComponent: function(){
        this.tpl = new Ext.XTemplate(           
            '<tpl for=".">',
                '<div name="postContainer" class="postContainer">',
                    // Contains Layout for posts
                '</div>',       

            {    // can run internal functions within a template
                createButton: function(idPost){
                    // Creates layout for buttons and returns it
                }
            }
        );

        this.callParent(arguments);
    }
});

And the two child views are:

Ext.define('Our.view.post.convList', {
    extend: 'Our.extensions.baseList',
    alias : 'widget.convList',  
    emptyText: 'No Conversation Followed',  
    title: 'Coversations',  

    initComponent: function(){      
        this.store = new Ext.create('Ext.data.Store', {
            id:'convStore',
            model: 'Our.model.Post',
            data: []
        });     

        this.callParent(arguments);
    }
});

And:

Ext.define('Our.view.post.postList', {
    extend: 'Our.extensions.baseList',  
    alias : 'widget.postList',
    emptyText: 'No Posts',
    title: 'Posts'
});

Ultimately, my question is does Ext.view.View actually support the autoScroll config property (or does it just ignore it as it seems to), which is listed in the Sencha docs as a valid config property. I know that it doesn't support the layout config hence why the linked questions solution failed to work. If it does support it, how would I go about getting the scroll bars to show up?

EDIT

Some things I've discovered in my attempts to come up with a solution, setting a size on the View itself works as long as the size is hard coded (a set number of pixels). Such as adding the config: height: 500, or a CSS class with height: 500px; but percentage sizes through CSS classes don't work at all - they don't even size the component.

SECOND EDIT

As I stated in comments to the first answer received, the component was getting the size 1063 (a note is that, the development environment is on a 1080x1920 monitor (in portrait) and with the JavaScript Console running in Chrome it's the height of the visible frame is 1063 pixels. By 'visible' I mean the postPanel that the Views are being added to.

I have found a temporary solution, unfortunately I don't think it's ideal for an actual production release - I'm using the refresh of the XTemplate to set the height of the component to the height of the panel to that of the postPanel (which sets the same height as it has been receiving) and this seems to force it to apply the scroll bars. I also added a listener to the resize event of the postPanel that fires the refresh event of the two Views.

The additions...

to the child views:

listeners: {
    refresh: function() {
        var parent = this.up('postPanel');
        if (parent != undefined) {
            this.setSize({
                width: undefined,
                height: parent.getHeight()
            });
        }
    }
}

and to the postPanel:

listeners: {
    resize: function() {
        var postList = this.down('postList');

        if (postList != undefined) {
            try {
                postList.fireEvent('refresh');
            } catch(e) { /* ignored */ }
        }

        var convList = this.down('convList');

        if (convList != undefined) {
            try {
                convList.fireEvent('refresh');
            } catch(e) { /* ignored */ }
        }
    }
}

The main reason I feel this is not an ideal solution is that it's broken the views automatic resizing to half the width of the parent (and setting the width to parent.getWidth() / 2 in the this.setSize() call in the refresh event doesn't alter the size at all, even if the parent is resized. In addition to that, I'm not sure if this will add any overhead to slower computers or not.

Community
  • 1
  • 1
Brandon Buck
  • 7,177
  • 2
  • 30
  • 51

2 Answers2

1

So the autoScroll should work as long as the component knows the size of the box it is supposed to fit in. If you don't want to set a specific box size try placing your view component into a viewport with fit layout. Then the viewport will dictate the size of the box and your view should start scrolling in the allocated space. This principal is used for all containers - some one somwhere must specify the size of the box. Viewport is the magic component that figures out the size of the full screen by default.

dbrin
  • 15,525
  • 4
  • 56
  • 83
  • The Views are added to the `postPanel` which is added to the content portion of the page, and I ran some tests - no matter what the size for the View is always static unless it's hard coded in a set size - which breaks the flow of the layout from resolution to resolution. I tried adding them to a Viewport, but Ext began complaining about DOM issues. – Brandon Buck Dec 09 '11 at 21:50
  • If you are not going to use the Viewport and want to have dynamic sizing you are going to have to do this by hand: 1. calculate initial size and 2. monitor page resize (see docs http://docs.sencha.com/ext-js/4-0/#!/api/Ext.EventManager-method-onWindowResize) . From viewport docs: "The Viewport does not provide scrolling, so child Panels within the Viewport should provide for scrolling if needed using the autoScroll config." - thats exactly what you want. – dbrin Dec 10 '11 at 00:36
  • There is already a `Viewport`, the panel that I'm using and the two listed View's are added to a child component of the `Viewport` and therefore I cannot add them directly to the `Viewport`. I have read the documentation and I have tried to set the `autoScroll` property and I have verified that the components were, in fact, getting the `overflow: auto;` CSS property like they should be - yet no scroll bars were appearing. I also verified that the `View` was getting a height set (that should have triggered the bars) as well. It did not work as I said. – Brandon Buck Dec 10 '11 at 18:21
  • What are the layouts specified on the parent components all the way to the root? I used Illuminations for Developers to troubleshoot layout issues. The layout examples on Sencha website are of tremendous help as well. http://docs.sencha.com/ext-js/4-0/#!/example/layout-browser/layout-browser.html Although it's possible you are seeing a bug, a more likely scenarios is a mistake in your layout composition. Provide the containership code from the top (viewport) so that we can try to spot an issue. – dbrin Dec 11 '11 at 05:44
0

Try to place each of your views in a container with layout: 'fix'. Then the autoScroll: true of the views will force the scroll bars, when the content requires it.

Darin Kolev
  • 3,401
  • 13
  • 31
  • 46
  • I know this isn't reflected anywhere but this is no longer an issue - we've long since abandoned Ext and that was due to the enormous number of bugs present in the 4.0 release and the lack of a 4.1 release being out to fix them when promised. I'm sure this issue has been resolved by those fixes (if they ever came) but again, we've abandoned the use of Ext. Thanks for the answer though! – Brandon Buck Apr 05 '13 at 15:03