How to set ExtJS center item to scroll horizontally in a border layout

I'm currently working on an ExtJS Viewport that includes a container with a border layout. My goal is to have the container in the center region support horizontal scrolling. The code snippet below shows how it's set up (this is within a Rails application, so please bear with the ERB code used for content rendering):

    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') %>'
                }
              ]
            }
          ]
        }
      ]
    }); 

The expected behavior is for the center container to become horizontally scrollable when the window width is less than 800px. However, the current implementation causes the content to overflow without enabling horizontal scrolling, although it appears as if there is enough space. Setting autoScroll to true only allows vertical scrolling when necessary.

How can I achieve the desired functionality?

Attempted the solution mentioned in a very similar question found at this link, but it didn't seem to work in my case.

Answer №1

One way to solve this issue is by enclosing the central region in a separate container with a fit layout, and then enabling the autoScroll property on this new container.

{
    defaultType: 'container',
    layout: 'fit',
    region: 'center',
    autoScroll: true, // NOTE: This is deprecated from version 5.1.0 onwards (use scrollable)
    scrollable: true, // Effective from version 5.1.0
    items: [ /* Place your current center panel here */ ]
}

To see a working example, check out this sample: http://jsfiddle.net/H4vp7/

Answer №2

I had to approach it in a slightly different way compared to Krzysztof's method.

In Ext JS v6+, I needed to explicitly set scrollable: true on the panel within the center region.

{
    xtype: 'panel',
    layout: 'border',
    items: [{
        xtype: 'toolbar',
        region: 'north',
        items: ['->', {
            xtype: 'button',
            text: 'Update'
        }]
    }, {
        defaultType: 'container',
        layout: 'fit',
        region: 'center',
        items: [{
            xtype: 'panel',
            scrollable: true, // ensure center panel is scrollable
            items: [ /* content of center panel */ ]
        }]
    }]
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The command "npm run build" is failing and encountering errors within the webpack project

Today, when I ran npm run build in the terminal, my project stopped running and displayed 90 errors and 13 warnings. It was working fine yesterday, so I'm not sure what the issue could be. The only change I made was to a line of JavaScript code that i ...

Using jQuery to dynamically insert variables into CSS styles

I am attempting to use jQuery 3 to modify the CSS of a class and change the background color. My first step is converting an rgba color code (properties.color) to a hexadecimal code, which is functioning correctly. Next, I try to change the background co ...

Guidelines for integrating historyAPI with AngularJS

I am currently working on developing a prototype similar to qz.com. Here is the strategy I am following: Create a function that loads the next piece of content when scrolling to the bottom of the page. This function will also update the URL using either ...

Is there a way to execute PHP scripts using JQuery or AJAX without causing the page to refresh?

REFRESHED CODE I'm attempting to execute PHP scripts within my main PHP file where all content will be presented. My goal is to exhibit the outcomes from my PHP script including the SQL queries in use. I also aim to implement the feature of showcasin ...

retrieve data from JSON file

function retrieveDataFromProfiles(){ const fs = require('fs') fs.readFile('src/data/profileInfo.json', function(error, data){ if(error){ alert(error); } var profileData = JSON.parse(data); //retrieves the JSON data of ...

JavaScript Time Counter: Keeping Track of Time Dynamically

Currently, I am attempting to create a dynamic time counter/timer using JavaScript. Why dynamic? Well, my goal is to have the ability to display days/hours/minutes/seconds depending on the size of the timestamp provided. If the timestamp is less than a d ...

Displaying angular ng-messages only when the field has been touched

Nothing too out of the ordinary here. I need my input to be validated with each keystroke. If the validation fails, I want the error message to display right away, without waiting for the blur event to trigger the $touched function. I assumed this was th ...

Tips for setting a value from an AJAX-created element into a concealed form field

There is a div that contains a button. When the button is clicked, a form appears. The div's id is then assigned to a hidden field within the form. This functionality works for the divs that are present on the page when it initially loads, but it does ...

Reverse a filter within an ng-repeat loop - AngularJS

I have a question that I haven't found the answer to yet. Here is the issue I'm facing: The JSON data I am working with has this structure: [{ "batch_queue_name": "Batch One", "start_date": "12/01/2016 10:18 P.M.", "end_date": "12/03/2016 ...

What is the best way to link to this list of options?

#episode-list { padding: 1em; margin: 1em auto; border-top: 5px solid #69c773; box-shadow: 0 2px 10px rgba(0,0,0,.8) } input { width: 100%; padding: .5em; font-size: 1.2em; border-radius: 3px; border: 1px solid #d9d9d9 } <div id="epis ...

How to toggle a class using ng-click in AngularJS

Currently, I am working on a project using AngularJS for my website. One specific feature involves having a form that is initially hidden with "display:none" set deliberately. There's also a button labeled create. My goal is to have the form toggle b ...

Utilize JavaScript to assign a button with identical functionality as another button

After developing a slick slider, I decided to add custom arrows. The standard method from slick involves using prevArrow: and nextArrow:, but I wanted the buttons outside of the slick-slider container. To achieve this, I placed additional prev and next but ...

WebAPI provides a similar functionality to an array in JavaScript through the use of IQueryable

I have a WebAPI method that returns an IQueryable of a 'complex' object in the following format: [Route("api/INV_API/deptSelect")] public IQueryable<DEPTNAME_DESCR> GetDistinctDeptSelect([FromUri] string q) { if (q != null) ...

Generate a fresh array using the information extracted from a JSON file

I need assistance in extracting a new array from JSON data. The desired output should be an array containing "itog" values. [12860498,20156554,19187309] [ { "0": { "itog": 12860498, "return": ...

Utilizing Observable Data in Angular 4 TypeScript Components

Looking to extract and assign a JSON value obtained from an API into a variable. Here is an example: TS this.graphicService.getDatas().subscribe(datas => { this.datas = datas; console.log(datas); }); test = this.datas[0].subdimensions[0].entr ...

Troubleshoot: Json causing issue with displaying markers on Google Maps API (v3)

I developed a custom Google Maps application using JSON data and implemented PostgreSQL database integration. Here is the code snippet: <script type="text/javascript"> var map; var national = [{"lng":"-6.173319","city":"JAKARTA","lat":"106.818 ...

Tips for establishing a connection to a SQL CE database using JavaScript within Internet Explorer

I am currently working on a Browser Plugin that involves storing data in an SQLCE Database locally. My challenge is to display this saved data on a webpage within the browser by connecting to the local database and fetching the values using JavaScript. S ...

Tracking and monitoring the advancement of multiple ajax post requests

Currently, I am utilizing jQuery for multiple ajax POST requests. In order to effectively manage the success or failure of each request and track the overall progress of the entire batch, my goal is to update the UI with a progress bar and information on t ...

The foreach loop speeds through its iterations

Here is the loop that I am currently working on: client.users.forEach(user => { if (user.presence.status == "online") { fnHistory.userUpdate(user.id, status, false, message); } }); The function being called within this loop is as follo ...

Issue with optimizing in Webpack 4

It's past 2am and I find myself going crazy trying to identify an error. The console keeps repeating the message: "Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead." I've attempted modifyi ...