Results 1 to 9 of 9

Thread: Is there a way to set pageParam to be zero based

  1. #1
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    30

    Default Is there a way to set pageParam to be zero based

    I need my pageParam in my Ext.data.BufferedStore to start at 0 rather then 1.

    Any idea how to do this?

    By default it appends page=1 to my URLS, I want it to do what's it doing by start at 0 instead.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Kind of odd to have a page zero. How can you have a zero page?
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    30

    Default

    What kind of response is this?

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Quote Originally Posted by pisaacs View Post
    What kind of response is this?
    One trying to understand the logic behind needing a page zero. It seems there is some server side code that is using page incorrectly, there is no page zero.

    It's like this, if you are in a car but stopped so your speed is zero, you have no speed. So if you want page zero, you have no data. Just doesn't make sense.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  5. #5
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    30

    Default

    Thanks for you feedback, but again, I asked how to reset the number, not for your opinions on how our backend was developed.

  6. #6
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    To reset the page to the initial page, use loadPage on the store:

    Code:
    store.loadPage(1);
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  7. #7
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    30

    Default

    Not exactly what I was asking. I was looking for how to set the pageParam to start at 0 instead of 1. I appreciate you trying to help.

    Anyone else?

  8. #8
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    No, I literally answered your "how to reset the page" question, use loadPage(1) to reset it to the first page. Page zero doesn't make sense at all. To calculate the start index, you use the page and page size:

    Code:
    (page - 1) * size
    That is code from the loadPage method. So if you have a nonsensical page of zero, that will be -1 * 25 which will give you a start index of -25 which is invalid.

    I'm trying to help you realize that page zero is just invalid to have.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  9. #9
    Sencha Premium Member
    Join Date
    Jun 2011
    Location
    NL
    Posts
    253
    Answers
    22

    Default

    I agree with Mitch that it would be better to fix the backend, but from a practical point of view I can totally understand that not everyone has full control over their backend.

    In another thread by pisaacs I already showed how to make a custom proxy and how to implement your own buildUrl() method in it. A zero based page param (call it pageIndex if you like) can be done in a similar way, for example like this:

    Code:
    buildUrl: function(request) {
        var me = this,
            page = request._params['page'],
            url = me.getUrl(request);
    
        if (page) {
            url += '?pageIndex=' + (page-1);
            delete request._params['page'];
        }
        me.setUrl(url);
        return me.callParent(arguments); 
    }

Similar Threads

  1. [CLOSED] SA 3.0.2 Bug: Cannot set Ext.data.proxy.Server.pageParam to boolean value
    By cdt in forum Sencha Architect 3.x: Bugs
    Replies: 11
    Last Post: 28 Jan 2014, 7:45 PM
  2. How to set pageParam to undefined using Architect?
    By [email protected] in forum Sencha Architect 2.x: Help & Discussions
    Replies: 2
    Last Post: 5 Sep 2013, 6:38 AM
  3. Connecting architect based app via ExtDirect based PHP/MySQL connection
    By premapix in forum Sencha Architect 2.x: Help & Discussions
    Replies: 0
    Last Post: 28 Aug 2012, 9:17 AM
  4. [FIXED] [PR4] Ajax proxy pageParam ignored
    By ASraniel in forum Sencha Touch 2.x: Bugs
    Replies: 3
    Last Post: 28 Jan 2012, 1:08 AM
  5. Replies: 2
    Last Post: 25 Mar 2011, 5:25 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •