Paging in Ext JS does not function properly when using local data sources

I am facing an issue with enabling paging in ExtJs4 grid. The paging toolbar appears to be functioning correctly, however, the paging feature does not seem to work within the grid itself. Can anyone provide guidance on what might be missing?

Ext.onReady(function () {
        var i = 1;

    Ext.define('User', {
        extend: 'Ext.data.Model',
        fields: [
             { name: 'id', type: 'int' },
             { name: 'firstName', type: 'string' },
             { name: 'lastName', type: 'string' },
             { name: 'age', type: 'int' },
             { name: 'eyeColor', type: 'string' }
        ]
    });

It seems that there is a problem with totalCount, but there may be something else contributing to the issue.

  var store=  Ext.create('Ext.data.Store', {
      model: 'User',
      totalCount:50,
      pageSize: 10,
      autoLoad: { start: 0, limit: 10 },

      proxy: {
          type: 'memory',
          reader: {
              root: 'users',
              totalProperty: 'totalCount'
          }

      },

  data: [
         { id: i++, firstName: 'Ed', lastName: 'Spencer', age:20, eyeColor: 'blue' },
         { id: i++, firstName: 'Tommy', lastName: 'Maintz', age: 30, eyeColor: 'black' },
         { id: i++, firstName: 'Aaron', lastName: 'Conran', age: 40, eyeColor: 'blue' },
         { id: i++, firstName: 'Jamie', lastName: 'Avins', age: 50, eyeColor: 'black' },
         { id: i++, firstName: 'Ed', lastName: 'Spencer', age: 20, eyeColor: 'blue' }

                                                 .
                                                 .
                                                 .

        ]
    });

Although the paging toolbar is functional, the values in the grid do not change based on the page numbers.

     Ext.create('Ext.grid.Panel', {
        title: 'Users',
        store: store,
        proxy: {
            type: 'memory',
            enablePaging: true
        },
        columns: [
              { header: 'ID', dataIndex: 'id', width:50 },
            { header: 'Name', dataIndex: 'firstName' },
            { header: 'Last Name', dataIndex: 'lastName' },
            { header: 'Age', dataIndex: 'age', width: 50 },
            { header: 'Eye Color', dataIndex: 'eyeColor' }

        ],
        height: 600,
        width: 800,
        dockedItems: [{
            xtype: 'pagingtoolbar',
            store: store,
            pageSize: 10,
            dock: 'bottom',
            displayInfo: true
        }],
        renderTo: Ext.getBody()
    });


});

Answer №1

To enable paging with local data, you should utilize the proxy: 'pagingmemory', specifically the Ext.ux.data.PagingMemoryProxy.

Referencing the documentation:

Utilizing Paging with Local Data

Paging functionality can be achieved with local data through the following extensions:

  • Ext.ux.data.PagingStore
  • Paging Memory Proxy (examples/ux/PagingMemoryProxy.js)

It's important to note that certain configurations are unnecessary when using this method:

  • totalCount in the store configuration (as it is provided by the proxy);
  • proxy on the grid (as it is already specified within the store);
  • pageSize in the paging toolbar configuration (as it will be retrieved from the store).

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

Switching code from using .hover() to using .click() while still maintaining the functionality of both.orChanging code to switch

How can I change this script to trigger on click and also maintain the hover functionality: $x = jQuery.noConflict(); $x(document).ready(function () { $x(".swatch-anchor").on('click hover', function () { var newTitle = $x(this).attr( ...

Exploring ways in JavaScript to locate every occurrence of a string within segments of URLs embedded in HTML code

I have a large HTML file (~50MB) and I need to extract all instances of strings that are between two specific strings (which contain forward slashes) in URLs. var content = '<div><a href="https://sample.org/something/here/091209283/?para ...

Using the built-in http module in node.js to upload images via multipart/form-data

I have encountered an issue where I need to send two images and an API key as part of a multipart/form-data HTTP request to an API. The images are retrieved from an AWS S3 bucket, which works fine. However, when attempting to send the image data as part ...

Angular 1.5 - Component for fetching HTML content with dynamic data

Help needed with using Angular Component method. Developing a main html file with its main controller containing a JSON list of client data: clients: [{ "name": "John Jackson", "age": "21", "hair": "brown", }, { "name": "Janet Doe", ...

Is it safe to securely store connection credentials in javascript?

I am currently working on developing a web chat app for a Minecraft server using this API. However, the demo script I am referring to displays connection information in plain text, making it easily visible to any client's computer. Is there a way to s ...

Having trouble with Jquery's Scroll to Div feature?

When I click on the image (class = 'scrollTo'), I want the page to scroll down to the next div (second-container). I've tried searching for a solution but nothing seems to work. Whenever I click, the page just refreshes. Any help would be gr ...

Preserving quotation marks when utilizing JSON parsing

Whenever I try to search for an answer to this question, I am unable to find any relevant results. So please excuse me if this has been asked before in a different way. I want to preserve all quotation marks in my JSON when converting from a string. In m ...

Uploading images seamlessly through ajax

Despite the abundance of tutorials, I am struggling to make them work. In my input form for file upload, I have: <input onChange="userPreviewImage(this)" type="file" accept="image/*" style="display:none"/> Here is my Javascript code: function use ...

What is the best way to access query string values using JavaScript?

Is it possible to retrieve query string values without using a plugin in jQuery? If the answer is yes, how can this be accomplished? If not, are there any plugins available that can help with this task? ...

Saving form blueprints and operations in a Data Repository

My team and I are working on a sophisticated web application with a complex back end. We have hundreds of form schemas paired with their corresponding return functions, which are triggered upon form submission. These JSON objects dynamically generate forms ...

What is the best way to incorporate a search feature within Bootstrap cards?

I've been struggling to incorporate a search feature within my bootstrap cards. Despite trying various online methods, none have proven successful for me so far. Below is my HTML code - any assistance in implementing a search filter into my app would ...

Updating the "title" attribute dynamically using jQuery in real time

I have a span that displays data in a tooltip every second, fetched from the server: <span class="info tooltip" title="{dynamic content}"></span> To show the tooltip, I'm using the tooltipsy plugin: $('.tooltip').tooltipsy({ ...

Creating a full-screen loading animation that appears when a button is clicked is a great way to enhance user experience. This animation can flow seamlessly from right to left before disappearing, providing a visually engaging transition for users as they

Despite anticipating more negative responses than positive ones, I believe that even one correct answer outweighs it all! So, I'm trying to figure out how to create a loading animation that covers the entire screen whenever a button on the navigation ...

The jQuery ajax function is not properly displaying or hiding the loader div

While attempting to call PHP code using a jQuery AJAX function, I encountered an issue where I wanted to display a loader div while the request was being sent and then hide the div once the request was complete. To simulate this scenario, I deliberately de ...

Making a POST request with ajax in Django

I encountered some difficulties while attempting to send a POST request using ajax in Django. I have searched various resources, but have not yet found a solution. Below is the javascript code that I am using, following this guide: $.ajax({ url: &apo ...

A guide to increasing a loop counter in Vue

Having trouble looping through a specific group of objects in a multi-object array? Take a look at the code below: <template> <div> <h1>My Test App</h1> <button v-on:click="getHockeyData">Get Team Data< ...

Getting the JavaScript file name within another JavaScript file - a simple guide

Imagine having an HTML file that references two external JavaScript files. One of these JavaScript files contains errors (likely compilation errors), while the other file includes an onerror method without any issues. When you open the HTML file in a brows ...

Encountered a build issue following the Svelte update: The subpath package './compiler.js' is not recognized by the "exports" definition

Challenge After updating from Svelte version 3.0.0 to the latest using npm i svelte@latest, I encountered an issue where my application would not run and constantly displayed the following error: [!] Error: Package subpath './compiler.js' is n ...

What is the best way to retrieve the ajax response using Ajax.Responders in prototype.js?

I am looking to retrieve the response of each Ajax call within the function below Ajax.Responders.register({ onCreate: function() { }, onComplete: function(transport) { }, onSuccess: function(transport) { }, }); ...

Redux - Refreshing the subtree state

How can I properly reset the subtree of a redux store without resetting the entire store? I want to target only the reducer subtree in question. Check out this example code: //initial state const initialState = { isFetching: false, error: '& ...