Author Topic: getting current values of rPP and curPage  (Read 5263 times)

lucafik

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 17
    • View Profile
getting current values of rPP and curPage
« on: November 06, 2014, 08:34:42 pm »
I already have a server function for fetching pages of data. It receives a current page, and number of records per page.

I want to submit current page of the grid to that function. At the moment I am doing pageModel.curPage, but that doesnt change from its initial value.

As a result, when I page through data, I always get the first page.

var pageM = {
            type: 'remote',
            curPage: 1,
            rPP: 30,
            rPPOptions: [5, 30, 50]
        }
var dataM = {
....
getUrl: function () {
                return { url: "JqueryGridHelper.aspx", data: "cur_page=" + pageM.curPage + "&records_per_page=" + pageM.rPP  };
            },
}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6087
    • View Profile
Re: getting current values of rPP and curPage
« Reply #1 on: November 06, 2014, 09:10:01 pm »
The problem is you have been using the old instance of pageM object which is deep cloned by the jQueryUI constructor. Correct way is to take fresh instance of pageModel.

getUrl: function (ui) {
         var PM = ui.pageModel;
         return { url: "JqueryGridHelper.aspx", data: "cur_page=" + PM.curPage + "&records_per_page=" + PM.rPP  };
},

lucafik

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: getting current values of rPP and curPage
« Reply #2 on: November 06, 2014, 10:03:09 pm »
fast and exactly what i need, thanks a lot!