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

Is react-particles-js still compatible for me to integrate?

I recently discovered that the package found here: https://www.npmjs.com/package/react-particles-js has been deprecated. Can I still utilize this package? The codes in question can be viewed at: https://codesandbox.io/s/particle-js-background-forked-woypk ...

What is the process for creating URL query parameters?

What is the process for generating parameters after node?_=xxxxxx? If I am using a Python script to access the URL, how can I retrieve these parameters? edit: I apologize for not providing enough information. This is my first post as a novice. I am atte ...

Substitute this.bindMethod for function component

I have a class component that is structured like this: interface MyProps { addingCoord: any resetCoords: any } interface MyState { x: any y: any } class DrawerOld extends React.Component<MyProps, MyState> { width: number height: number ...

The Npm generate script is failing to create the necessary routes

I've integrated vue-router into my nuxt project, but I encountered an issue when running npm run generate - it generates everything except for my pages. I suspect the problem lies with the router implementation as I didn't face any issues before ...

The method "_super" is not supported by the object in igGrid

When using infragistics and igGrid in my application, I encountered a javascript error. The error message reads: "Object doesn't support property or method "_super" Although I understand how to resolve this issue, I have decided to provide a fake ...

Is there a way to update a child component in React when the parent state changes, without utilizing the componentWill

I am currently working on developing a JSON editor using React, but I am facing an issue with the library I am utilizing not having a componentWillReceiveProps hook. As someone relatively new to React, I am trying to find a way to automatically update th ...

Encountering a problem with loading ajax data in jVectorMap

I'm currently facing an issue where I am unable to load data from visitors into a map created using the jvectormap plugin. This problem is really frustrating me as I can't seem to fetch the data through ajax, although it works fine when I input ...

What is the integration process of using Font Awesome with React?

After installing react-create-app using npm, I also added react-fontawesome. Now, I'm wondering how to include the css styles of fontawesome in my project? Here is a glimpse of my work space: https://i.stack.imgur.com/pM1g1.png ...

Why does trying to package a Windows app on OSX prompt a request for Wine installation?

For several months, I have been successfully utilizing Electron on macOS (10.11.6) to create and package both OSX and Windows applications. My current setup includes electron v1.7.3 and "electron-packager" "^8.5.2", all of which have not been updated in a ...

Material-UI Autocomplete can only save and display one specific property of an object at a time

Can someone help me with implementing Autocomplete from Material-UI? I want to store only a specific property value and not the entire object. For example, let's say I want to store the property Value, but it could be any other property as well. con ...

How to Display Prices in Euros Currency with Angular Filter

Can someone help me figure out how to display a price in euros without any fractions and with a dot every 3 digits? For example, I want the price 12350.30 to be shown as 12.350 €. I attempted to use the currency filter but it only worked for USD. Then ...

issue with useReducer not functioning as expected

I encountered an issue with my customized Select component. It includes a select and options while listening for onChange events. Additionally, I am using a useReducer function that initializes some variables. However, even after selecting an option, the s ...

Utilizing properties to transfer a reference object to a nested component

Is it safe to do the following in React: function Parent() { const myRef = useRef([1, 2, 3]); console.log("parent: " + myRef.current); return <Child myList={myRef.current} />; } function Child({ myList }) { const [currInt, setCurrInt] = useS ...

Different ways to activate the system bell in Node.js

Currently, I have a custom nodejs script running for an extended period and I'm seeking a way to receive a notification once the script finishes its execution. Is there a method in nodejs that can be used to activate the "System Bell" alert? ...

What benefits does using Object.create(null) offer in comparison to utilizing a Map?

I've noticed that some developers prefer using code that looks like const STUFF_MAP = Object.create(null); It seems that STUFF_MAP is intended to be used like a map, hence the choice of using Object.create(null) over {} (to avoid conflicts with prope ...

Ways to filter and display multiple table data retrieved from an API based on checkbox selection in Angular 2 or JavaScript

Here is a demonstration of Redbus, where bus data appears after clicking various checkboxes. I am looking to implement a similar filter in Angular 2. In my scenario, the data is fetched from an API and stored in multiple table formats. I require the abili ...

ng-model in html input with a name of "foo[]"

Apologies for the lack of a more specific title. In HTML, when we need multiple values for a given name, we utilize the name="foo[]" attribute. Upon posting the data, it arrives as an array. I am seeking this same functionality with ng-model in Angular. ...

When the page is refreshed, reorienting axes in three.js encounters difficulties

I am currently working on a project that involves using the three.js editor source code available for download on the three.js website. As part of this project, I am required to adjust the orientation of the axes to align with standard airplane coordinate ...

A mistake has been identified: The object could potentially be 'null'. TS2531 for window.document

This is my first time integrating TypeScript into my project. When attempting to access something using window.document.getElementById(), I keep encountering the error: Type error: Object is possibly 'null'. TS2531 I've looked online for ...

Can pagination numbers in Jquery DataTable be configured based on the total records returned by the server and the number of records chosen by the user?

I am currently diving into the world of DataTable.js, a jQuery plugin, and working hard to articulate my questions effectively. For my specific needs, I need to retrieve only 10 records initially whenever an AJAX request is made, even if there are 100 rec ...