1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    15
    Vote Rating
    1
    webdev2111 is on a distinguished road

      0  

    Exclamation Unanswered: paging not correctly

    Unanswered: paging not correctly


    My paging doesnt seem to be working correctly. I am trying to display 3 result perpage.. but it showing all in one page and when you click next page it repeating the same results 2nd page and so forth. How can i fix this?

    Ext.require([
    'Ext.data.*',
    'Ext.grid.*'
    ]);

    Ext.onReady(function(){
    Ext.define('Book',{
    extend: 'Ext.data.Model',
    fields: [
    // set up the fields mapping into the xml doc
    // The first needs mapping, the others are very basic
    {name: 'Author', mapping: 'ItemAttributes > Author'},
    'Title', 'Manufacturer', 'ProductGroup'
    ]
    });

    // create the Data Store
    var store = Ext.create('Ext.data.Store', {
    pageSize: 3,
    model: 'Book',
    autoLoad: true,
    proxy: {
    // load using HTTP
    type: 'ajax',
    url: 'sheldon-2.xml',
    // the return will be XML, so lets set up a reader
    reader: {
    type: 'xml',
    // records will have an "Item" tag
    record: 'Item',
    idProperty: 'ASIN',
    totalRecords: '@total'
    }
    }
    });

    // create the grid
    var grid = Ext.create('Ext.grid.Panel', {
    store: store,
    columns: [
    {text: "Author", flex: 1, dataIndex: 'Author', sortable: true},
    {text: "Title", width: 180, dataIndex: 'Title', sortable: true},
    {text: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
    {text: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
    ],
    renderTo:'example-grid-group-v3',
    width: 540,
    height: 200,
    // paging bar on the bottom
    bbar: Ext.create('Ext.PagingToolbar', {
    store: store,
    displayInfo: true,
    displayMsg: 'Displaying topics {0} - {1} of {2}',
    emptyMsg: "No topics to display"

    })
    });
    });

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,084
    Answers
    112
    Vote Rating
    95
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    Paging has to be implemented on the backend too. It seems that you are reading from an XML file. When the store sends a request (when paging is being used), the start and limit parameters are sent in that request and the backend has to be able to send back just those records to the store. In case of this file, its always the same data being sent to the store.

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    15
    Vote Rating
    1
    webdev2111 is on a distinguished road

      0  

    Exclamation paging not correctly

    paging not correctly


    Thanks..If i am using server side xml feed , where will the start and limit be added or is it added automatically how do i go about settign it up correctly?

    Thanks

  4. #4
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,084
    Answers
    112
    Vote Rating
    95
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    I dont know exactly how you can do it with XML but here is what you need to consider: when the store sends a paging request, you will see that in the URL, there is a start and limit parameter. These values are based on the page you are trying to access and the page size. On the server side, you have to be able to read these parameters, read your data from XML file etc. and send the requested range of data to the store.

Thread Participants: 1