Author Topic: totalPages for remote pageModel  (Read 4584 times)

lucafik

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 17
    • View Profile
totalPages for remote pageModel
« on: November 05, 2014, 05:07:44 pm »
I have a problem with setting totalPages. In free version, totalPages was set automatically, but now its not.

I already have a helper .NET method that worked for free version, and I use it with getUrl, so since I switched to PRO I dont want to change it, I want to keep using the same method (without parameters, gets them from querystring).

I have read this example
http://paramquery.com/pro/demos/paging

I dont understand how is totalPages set. I read that for remote you need to set it manually, but in this example it is not set.

Here is relevant part of my code

var pageM = {
            type: 'remote',
            curPage: 1,
            totalPages: 3,
            rPP: 30,
            rPPOptions: [5, 30, 50]
        }   
        var dataM = {
            location: "remote",
            sorting: "remote",
            dataType: "JSON",
            method: "POST",
            sortIndx: 0,
            sortDir: "up",
            getUrl: function () {
               
            },
            getData: function (dataJSON, textStatus, jqXHR) {
                $("#patients_loader").hide();
                $(".container_patientlist").show();

                if (dataJSON != null)
                {
                    return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON.data };
                }         
            }
        }

 var $gridPatients = $("#grid_patientlist").pqGrid({ width: "auto", height: 700,
            dataModel: dataM,
            pageModel: pageM,
            colModel: colM,
            resizable: false, 
            showTop: false,
            showBottom: true,
            flexHeight: true,
            editable:false,
            columnTemplate : { width: '10%' },
            selectionModel: { type: 'none' }  ,
            scrollModel: {autoFit: true}   
        });



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: totalPages for remote pageModel
« Reply #1 on: November 05, 2014, 11:02:12 pm »
In this demo http://paramquery.com/pro/demos/paging grid sends the paging parameters i.e., pq_curPage and pq_rPP on its own which are received by the remote .NET method.

public ActionResult paging(int pq_curPage, int pq_rPP)

Either url or getUrl is required for remote requests.

http://paramquery.com/pro/api#option-dataModel-url

Moreover you don't need to set or modify pageModel.totalPages as totalPages are calculated automatically by the grid based on totalRecords. You only need to return totalRecords, curPage and data from the remote method as shown in the remote paging example.
« Last Edit: November 05, 2014, 11:13:17 pm by paramquery »

lucafik

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: totalPages for remote pageModel
« Reply #2 on: November 06, 2014, 08:27:26 pm »
thanks, it works.

it seems it was some other bug that caused the issue.