<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: How to Paginate please</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on How to Paginate please</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31129</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31129</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Â </p>
<p>I recommend you toÂ <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data" target="_blank">read this documentation</a>Â - maybe the whole chapter.</p>
<p>Â </p>
<p>Kind Regards</p>
]]></description>
        	        	<pubDate>Sat, 13 Sep 2014 13:41:35 +0300</pubDate>
        </item>
        <item>
        	<title>coachz on How to Paginate please</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31113</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31113</guid>
        	        	<description><![CDATA[<p>I had to write the entire paginator.......</p>
<p>Â Â Â  // coming in from jqGrid<br />
Â Â  Â Â Â  Â Log::info(Input::all());<br />
Â Â  Â Â Â  Â Â Â  Â // array (<br />
Â Â  Â Â Â  Â Â Â  Â //Â Â  '_search' =&#62; 'false',Â Â  Â Â Â  Â Â Â  Â // search enabled<br />
Â Â  Â Â Â  Â Â Â  Â //Â Â  'nd' =&#62; '1410449702065',<br />
Â Â  Â Â Â  Â Â Â  Â //Â Â  'per_page' =&#62; '10',<br />
Â Â  Â Â Â  Â Â Â  Â //Â Â  'current_page' =&#62; '1',<br />
Â Â  Â Â Â  Â Â Â  Â //Â Â  'sidx' =&#62; 'CompanyName',<br />
Â Â  Â Â Â  Â Â Â  Â //Â Â  'sord' =&#62; 'desc',<br />
Â Â  Â Â Â  Â Â Â  Â // )</p>
<p>Â Â  Â Â Â  Â $page = Input::get("page", 1);Â Â  Â // get the requested page<br />
Â Â  Â Â Â  Â $limit = Input::get("rows"); // get how many rows we want to have into the grid<br />
Â Â  Â Â Â  Â $sidx = Input::get("sidx", 1); // get index row - i.e. user click to sort<br />
Â Â  Â Â Â  Â $sord = Input::get("sord", "asc"); // get the direction<br />
Â Â Â Â  Â Â Â  Â if (!$limit) $limit = 25;</p>
<p>Â Â  Â Â Â  Â $count = DB::table('customers')-&#62;count();<br />
Â Â  Â Â Â  Â <br />
Â Â  Â Â Â  Â // calculate the total pages for the query<br />
Â Â  Â Â Â Â  if( $count &#62; 0 &#38;&#38; $limit &#62; 0) {<br />
Â Â  Â Â Â Â Â Â Â Â  $count = ceil($count/$limit);<br />
Â Â  Â Â Â Â  } else {<br />
Â Â  Â Â Â Â Â Â Â Â  $count = 0;<br />
Â Â  Â Â Â Â  }<br />
Â Â  Â Â Â  Â <br />
Â Â  Â Â Â Â  // if for some reasons the requested page is greater than the total<br />
Â Â Â  Â Â Â  Â // set the requested page to total page<br />
Â Â  Â Â Â  Â if ($page &#62; $count) $page=$count;</p>
<p>Â Â  Â Â Â  Â // calculate the starting position of the rows<br />
Â Â Â Â  Â Â Â  Â $start = $limit * $page - $limit; // do not put $limit*($page - 1)</p>
<p>Â Â  Â Â Â  Â // if for some reasons start position is negative set it to 0<br />
Â Â Â Â  Â Â Â  Â // typical case is that the user type 0 for the requested page<br />
Â Â Â Â  Â Â Â  Â if($start &#60;0) $start = 0;</p>
<p>Â Â Â Â  Â Â Â  Â Log::info($sidx . "&#124;" . $sord . "&#124;" . $limit . "&#124;" . $start);</p>
<p>Â Â  Â Â Â  Â $results = DB::table('customers')-&#62;orderBy($sidx, $sord)-&#62;take($limit)-&#62;skip($start)-&#62;get();<br />
Â Â  Â Â Â  Â <br />
Â Â  Â Â Â  Â Log::info($results);<br />
Â Â  Â Â Â  Â //$paginationResults = Paginator::make( $rows, $count, $page);<br />
Â Â  Â Â Â  Â Â Â  Â  //$items - record set of query result<br />
Â Â  Â Â Â  Â Â Â  Â  //$total - number of records into fetch result<br />
Â Â  Â Â Â  Â Â Â  Â  //$per_page - number of records per page you want</p>
<p>Â Â  Â Â Â  Â //$results = Customer::all();<br />
Â Â  Â Â Â  Â //$arr = ["page" =&#62; 1, "records" =&#62; 4, 'total'=&#62; 2, 'rows' =&#62; $results];<br />
Â Â  Â Â Â  Â $arr = ["page" =&#62; $page, "records" =&#62; $limit, 'total'=&#62; $count, 'rows' =&#62; $results];<br />
Â Â  Â Â Â  Â //return Response::json($arr);</p>
<p>Â Â  Â Â Â  Â return Response::json($arr);</p>
]]></description>
        	        	<pubDate>Fri, 12 Sep 2014 22:12:23 +0300</pubDate>
        </item>
        <item>
        	<title>wexwell on How to Paginate please</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31104</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31104</guid>
        	        	<description><![CDATA[<p>This is what you are returning with your code;</p>
<pre class="json">"total": 91,
Â  "per_page": 10,
Â  "current_page": 1,
Â  "last_page": 10,
Â  "from": 1,
Â  "to": 10,
Â  "data": [</pre>
<p>Â </p>
<p>If you would have actually compared to what I was sending you would have noticed your parameters are not set correctly for pagination to work.Â  One example - total is the total number of pages (the way I set it), you are setting it to the total number of records. The parameter I am setting (note - I didn't simply name my own I set them according to the documentation) for the current page is simply 'page', you are using current_page. If you analyze and adapt what I posted, or read the documentation on naming conventions, you should have no problem getting it to work.</p>
]]></description>
        	        	<pubDate>Tue, 09 Sep 2014 16:46:14 +0300</pubDate>
        </item>
        <item>
        	<title>coachz on How to Paginate please</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31102</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31102</guid>
        	        	<description><![CDATA[<p>I'm sorry but that didn't help me solve my problem.Â  I have pasted what the server is returning to the grid and what my grid config is.Â  Why do I not get any pagination or data showing up please ?</p>
]]></description>
        	        	<pubDate>Tue, 09 Sep 2014 13:45:22 +0300</pubDate>
        </item>
        <item>
        	<title>wexwell on How to Paginate please</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31073</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31073</guid>
        	        	<description><![CDATA[<p>Mine works fine and this is what I am sending back (and how I am sending it). I doubt my queries will do much good, I'm using mssql.</p>
<p>Â </p>
<div class="sfcode">
<pre class="brush-php syntax">$page = $_POST['page'];
$rows = $_POST['rows'];

$data['records']=$rowcnt;
$data['page']=$page;
$data['total']=$rowcnt/$rows;
$data['rows']=$result; //this is the data set from the query
echo json_encode($data);</pre></div>]]></description>
        	        	<pubDate>Fri, 05 Sep 2014 17:30:18 +0300</pubDate>
        </item>
        <item>
        	<title>coachz on How to Paginate please</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31051</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-paginate-please#p31051</guid>
        	        	<description><![CDATA[<p>How can I get my data grid to paginate and show data please?Â Â  My laravel controller sends back the following for pagination and below is my jqgrid config.Â  I have tried prmNames but I must be doing something wrong.Â  When I don't use pagination and just send back data, it jqgrid displays the data but when I send pagination and data I get no data displayed and no pagination.Â  Thanks for any help.</p>
<blockquote>
<pre class="json">{
Â  "total": 91,
Â  "per_page": 10,
Â  "current_page": 1,
Â  "last_page": 10,
Â  "from": 1,
Â  "to": 10,
Â  "data": [
Â Â Â  {
Â Â Â Â Â  "id": "ALFKI",
Â Â Â Â Â  "CompanyName": "Alfreds Futterkiste",
Â Â Â Â Â  "ContactName": "Maria Anders"
Â Â Â  },
Â Â Â  {
Â Â Â Â Â  "id": "ANATR",
Â Â Â Â Â  "CompanyName": "Ana Trujillo Emparedados y helados",
Â Â Â Â Â  "ContactName": "Ana Trujillo"
Â Â Â  }
Â Â Â  }
]


jqgrid code.........

&#60;div class="container"&#62;
Â Â  Â Â Â  Â &#60;span class="label label-default"&#62;My Grid&#60;/span&#62;
Â Â  Â Â Â  Â &#60;br /&#62;&#60;br /&#62;

Â Â  Â Â Â Â  &#60;table id="list"&#62;&#60;tr&#62;&#60;td&#62;&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62; 
Â Â  Â Â Â Â  &#60;div id="pager"&#62;&#60;/div&#62; 

Â Â Â  &#60;/div&#62;

Â $("#list").jqGrid({
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  url: "customersData",
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  datatype: "json",
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  mtype: "GET",
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  prmNames: {page: "current_page", rows: "per_page"},
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  //prmNames: {page: "pageIndex", sort: "sortCol", order: "sortDir", rows: "pageSize"},
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  colNames:['Unique Id', 'CompanyName', 'ContactName'],
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  colModel: [
Â Â  Â Â Â  Â Â Â  Â Â Â Â Â Â Â Â  { name: "id", width: 55 },
Â Â  Â Â Â  Â Â Â  Â Â Â Â Â Â Â Â  { name: "CompanyName", width: 55 },
Â Â  Â Â Â  Â Â Â  Â Â Â Â Â Â Â Â  { name: "ContactName", width: 55 }
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  ],
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  pager: "#pager",
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  rowNum: 3,
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  rowList: [10, 20, 30],
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  //width: 600,
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  autowidth: true,
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  height: "100%",
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  sortname: "CompanyName",
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  sortorder: "desc",
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  viewrecords: true,
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  gridview: true,
Â Â  Â Â Â  Â Â Â Â Â Â Â  // autoencode: true,
Â Â  Â Â Â  Â Â Â Â Â Â Â Â  caption: "My first grid"
Â Â  Â Â Â  Â Â Â Â  }); 



Â Â  Â Â Â  Â Â Â  Â $("#list").jqGrid('navGrid','#pager',{edit:true,add:true,del:true});


</pre>
</blockquote>
]]></description>
        	        	<pubDate>Wed, 03 Sep 2014 13:52:26 +0300</pubDate>
        </item>
</channel>
</rss>