Author Topic: Pager is not visible - PRO  (Read 14794 times)

eroque

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
Pager is not visible - PRO
« on: March 03, 2014, 09:23:21 pm »
I am migrating from Basic to PRO 2.0.4 and I have updated all the code successfully, no javascript errors. For some reason the pager is not visible any longer. What could be the reason for this behavior?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pager is not visible - PRO
« Reply #1 on: March 03, 2014, 09:30:20 pm »
PRO has a separate pageModel

http://paramquery.com/pro/api#option-pageModel

Please refer to the migration topic:

http://paramquery.com/pro/tutorial#topic-migration


eroque

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Pager is not visible - PRO
« Reply #2 on: March 03, 2014, 09:39:20 pm »
That is what I did. Still hidden. Question: totalPages has to be set for remote paging in the getData function?



eroque

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Pager is not visible - PRO
« Reply #3 on: March 03, 2014, 09:45:14 pm »
Solved!!! Thanks

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Pager is not visible - PRO
« Reply #4 on: June 16, 2014, 10:11:55 pm »
So how do you solve this problem? I can't get pager visible with the following code:
Also, what is a correct way of throwing errors from PHP server code so that they go to "error" section?


   var dataModel = {
           location: "remote",
           sorting: "local",
        // pageModel: { type: 'remote', curPage: 1, rPP: 20, rPPOptions: [10, 30, 50, 100, 200], totalPages:1000},
           pageModel: { type: "remote", rPP: 20, strRpp: "{0}", curPage: 1 },         
           dataType: "JSON",
           method: "POST",
           recIndx: "PlantID",
           getUrl: function (ui)
              {
                 var dataModel = ui.dataModel.pageModel;
                 var filters = { "name" : $("#txName").val(),
                             "curPage": dataModel.curPage,
                             "recPerPage": dataModel.rPP,
                                 };
                   return {
                    url: "../services/Search.php",
                     data: { dataBuffer: filters }
                };
            },
           getData: function (dataJSON)
           {
               var data = dataJSON.DataArray;               
               return { curPage: dataJSON.curPage, totalRecords:1000, data: data };
           },
           error: function (err)
           {
              alert ("Error: " + err + "\n Please contact administrator with your input!");
          }          
       };

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pager is not visible - PRO
« Reply #5 on: June 16, 2014, 10:38:14 pm »
1) pageModel is not a property of dataModel but it's a property of grid's constructor object similar to dataModel.

Example:

http://paramquery.com/pro/demos/paging

2) Throwing errors from PHP code can be displayed through error callback, it's correct the way you have done it already.
« Last Edit: June 16, 2014, 10:39:46 pm by paramquery »

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Pager is not visible - PRO
« Reply #6 on: June 16, 2014, 10:42:35 pm »
1. From this example I'm not sure how to capture curPage in my situation ($POST instead of $GET + filter parameters)

2. Could you give me an example of how to throw errors from PHP side? If I just remove try/catch block, it doesn't seem to work when error occurs, "alert" doesn't show up.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pager is not visible - PRO
« Reply #7 on: June 17, 2014, 06:05:57 pm »
1) curPage is sent to server as pq_curpage GET variable.

use dataModel.method = 'POST' if you want to handle the variables send by grid as $_POST variables.


======================================
Please create a separate post for your 2nd question.

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Pager is not visible - PRO
« Reply #8 on: June 17, 2014, 07:22:47 pm »
So when I use method "POST", it does not seem to have this parameter that you refer GET should have. So what is the way to access it via POST?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pager is not visible - PRO
« Reply #9 on: June 17, 2014, 07:38:10 pm »
It's straightforward: $_POST["pq_curpage"] instead of $_GET["pq_curpage"]

If you still don't see it please post

1)  entire code for grid especially dataModel

and

2) output of print_r($_POST)
« Last Edit: June 17, 2014, 07:43:26 pm by paramquery »

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Pager is not visible - PRO
« Reply #10 on: June 17, 2014, 07:55:30 pm »
Yeah, my POST only contains "dataBuffer" parameter that I have added to it.

return {
                    url: "../services/Search.php",
                     data: { dataBuffer: filters }
                };

I have posted dataModel code above. Is there anything specific you're looking for?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pager is not visible - PRO
« Reply #11 on: June 17, 2014, 08:06:25 pm »
your dataModel posted earlier needs corrections for pageModel.

Please post the corrected dataModel and pageModel.

and you need not implement getUrl in PRO

Please refer this demo:
http://paramquery.com/pro/demos/paging
« Last Edit: June 17, 2014, 08:09:56 pm by paramquery »

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Pager is not visible - PRO
« Reply #12 on: June 17, 2014, 08:15:32 pm »
If I do not implement getURL, how should I pass POST parameters for filtering? Example you're referring to is for GET as far as I can see so it doesn't help me much...

Also, the reason I use pageModel in my code is that I don't see other way to pass current page in POST request.

dbadmin

  • Pro Economy
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Pager is not visible - PRO
« Reply #13 on: June 17, 2014, 10:08:32 pm »
So with the following code
1. Pager is not visible
2. Could you tell me how to pass current page & records per page to a service via $POST ? In $GET example you referred me to I don't seem to find where filters are being passed to a service, it seems to be a plain call without parameters.

var dataModel = {
           location: "remote",
           sorting: "local",
           pageModel: { type: "remote", rPP: 20, strRpp: "{0}", curPage: 1 },         
           dataType: "JSON",
           method: "POST",
           getUrl: function (ui)
              {
                 var filters = { "Name" : $("#txName").val(),
                             "curPage": 1,
                             "recPerPage": 20
                                 };
                   return {
                    url: "../services/Search.php",
                     data: { dataBuffer: filters }
                };
            },
           getData: function (dataJSON)
           {
               var data = dataJSON.DataArray;                 
               return { curPage: dataJSON.curPage, totalRecords:1000, data: data };         
           },
           error: function (err)
           {
              alert ("Error: " + err + "\n Please contact administrator with your input!");
          }          
       };
      
   columnModel = [     
      {title:"Name", width:150, dataType:"string", align:"right", className:'grid-col', editable: false}
       ];
   $("#grid_array").pqGrid( {
      dataModel: dataModel,
      colModel: columnModel,
      showTitle: false,
       collapsible:false,
       scrollModel:  {pace: 'fast', horizontal: false},
       numberCell: { show: false },
       flexHeight:true,
       flexWidth:true,
       sortable:true,
       columnBorders:false,
       editable: true,
       editModel: {clicksToEdit: 1, saveKey: 13},
       sortable:true
   });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pager is not visible - PRO
« Reply #14 on: June 17, 2014, 10:31:31 pm »
Let's take one step at a time, forget about filter parameters and anything else for a while and correct paging issue which is also the title of this topic.

your paging is not visible because as mentioned earlier, pageModel is not at right place.

pageModel is not a property of dataModel but it's a property of grid's constructor object similar to dataModel.

Example:

http://paramquery.com/pro/demos/paging