使ExtJS边框布局的中心项水平滚动

G G*_*III 3 javascript extjs horizontal-scrolling border-layout extjs4

我有一个带有边框布局的容器的ExtJS视口,我想让中心区域的容器支持水平滚动.这就是代码现在的样子(这是Rails应用程序的一部分,所以请原谅提供一些内容的ERB代码):

    var viewport = Ext.create('Ext.container.Viewport', {
      defaultType: 'container',
      layout: 'border',
      items: [
        {
          defaultType: 'container',
          minWidth: 800,
          region: 'north',
          items: [
            <%= render "shared/header" %>
            ,<%= render "shared/title_bar" %>
          ]
        },{
          defaultType: 'container',
          minWidth: 800,
          region: 'center',
          autoScroll: true,
          items: [
            <%= ext_site_flash_panel(:alert, flash[:site_alert]) %>,
            <%= ext_site_flash_panel(:notice, flash[:site_notice]) %>,
            <%= ext_flash_panel(:alert, flash[:alert]) %>,
            <%= ext_flash_panel(:notice, flash[:notice]) %>,
            {
              defaultType: 'container',
              margin: '20 20 20 20',
              defaults: {
                margin: '0 0 15 0'
              },
              items: [
                <% if content_for?(:top_section) %>
                  <%= yield :top_section %>,
                <% end %>
                <%= content_for?(:main_content) ? yield(:main_content) : yield %>
              ]
            },{
              id: 'footer',
              defaultType: 'container',
              padding: '10 0 10 0',
              layout: {
                type: 'hbox',
                align: 'middle',
                pack: 'center'
              },
              items: [
                {
                  html: '<%= escape_javascript(render 'shared/copyright') %>'
                }
              ]
            }
          ]
        }
      ]
    }); 
Run Code Online (Sandbox Code Playgroud)

我期望的行为是,当窗口的大小使得中心容器的宽度小于800像素时,它将变得可滚动.相反,它只是从屏幕的一侧掉下来而不允许我滚动到它,虽然它仍然渲染,好像窗口有800像素以适应内容.已经autoScroll设置为true,似乎只,以确保当含量太大的窗口中我们可以垂直滚动.

我怎样才能获得理想的行为?

注意:试过在这个非常相似的问题中提到的解决方案,但它似乎不起作用.

Krz*_*tof 6

一种解决方案是将中心区域包装在具有适合布局的另一个容器中,并设置autoScroll在此新容器上.

{
    defaultType: 'container',
    layout: 'fit',
    region: 'center',
    autoScroll: true, // WARNING: deprecated since v5.1.0 (use scrollable)
    scrollable: true, // v5.1.0+
    items: [ /* your current center panel goes here */ ]
}
Run Code Online (Sandbox Code Playgroud)

工作样本:http://jsfiddle.net/H4vp7/