Author Topic: Not getting pq_rpp and pq_curpage not being passed in POST  (Read 2952 times)

stevejacobsen

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
I'm having trouble getting the pq_rpp and pq_curpage parameters passed in the post. When I use this.rPP and this.curPage it doesn't pass any values. If I hard code them to pq_rpp: 20, and pq_curpage: 1 I get the first page of data but then it of course doesn't allow me to advance to new pages of data.

Quote

$(function () {

//define colModel
    var colM = [
        {title: "Part", width: 120, dataIndx: "Part", align: "left", cls: 'result'},
        {title: "Description", width: 225, dataIndx: "Description", align: "left"},
        {title: "Price", width: 75, dataIndx: "Price", align: "right", dataType: "float"},
        {title: "Orig Price", width: 75, dataIndx: "Origprice", align: "right", dataType: "float"},
        {title: "Net Price", width: 75, dataIndx: "Net", align: "right", dataType: "float"},
        {title: "Supplier", width: 75, dataIndx: "Supplier", align: "center", dataType: "integer"},
        {title: "Updated", width: 100, dataIndx: "Updated", align: "right"}
    ];

    var dataModel = {
        location: "remote",
        dataType: "JSON",
        method: "POST",
        curPage: 1,
        getUrl: function (ui) {
            return {
                url: "utilities/ajax_get_catalog_data_JSON.php",
                data: {
                    pq_rpp: this.rPP,
                    pq_curpage: this.curPage
                }
            };
        },
        getData: function (dataJSON) {
            return {curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON.data};
        }
    };

    var obj = $("div#catalog_grid").pqGrid({
        width: 900,
        height: 400,
        dataModel: dataModel,
        colModel: colM,
        pageModel: {type: "remote", rPP: 20, strRpp: "{0}"},
        collapsible: false,
        wrap: false, hwrap: false,
        title: "Catalog",
        resizable: true
    });


    var grid = $("#catalog_grid").pqGrid(obj);

stevejacobsen

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Not getting pq_rpp and pq_curpage not being passed in POST
« Reply #1 on: May 26, 2016, 05:39:43 am »
I just noticed that I left  paging: "remote", out of the dataModel. I have added that and it hasn't changed the results.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6264
    • View Profile
Re: Not getting pq_rpp and pq_curpage not being passed in POST
« Reply #2 on: May 26, 2016, 03:39:31 pm »
It's because this points to js instance of the grid and this.rPP and this.curPage are undefined.

Anyway these parameters are automatically send by the grid.

Please check this example for remote paging: http://paramquery.com/pro/demos/paging

stevejacobsen

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Not getting pq_rpp and pq_curpage not being passed in POST
« Reply #3 on: May 26, 2016, 06:57:28 pm »
Okay, Thanks! I was using the tutorial for PHP and they indicated to use "this". It works now.