Title: Set a other default value for pagination ( not 10 -> 50 )
Post by: kavvson on July 29, 2014, 11:07:32 AM
My code <table id="dg" style="width:700px;height:250px" url="lists.php" pagination="true" sortName="created" sortOrder="desc" title="DataGrid - Expand Row" singleSelect="true" fitColumns="true"> <thead> <tr> <th field="id" width="80" sortable="true">Item ID</th> <th field="number" width="100" sortable="true">Product ID</th> <th field="created" align="right" width="80" sortable="true">List Price</th> </tr> </thead> </table> <script type="text/javascript"> $(function(){ $('#dg').datagrid({ view: detailview, detailFormatter:function(index,row){ return '<div class="ddv" style="padding:5px 0"></div>'; }, onExpandRow: function(index,row){ var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv'); ddv.panel({ height:80, border:false, cache:false, href:'listdetail.php?listnumb='+row.number, onLoad:function(){ $('#dg').datagrid('fixDetailRowHeight',index); } }); $('#dg').datagrid('fixDetailRowHeight',index); } }); }); </script> and my generator $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 50; $sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'date'; $order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
$offset=($page-1)*$rows; $rs = mysql_query("select count(*) from listy"); $row = mysql_fetch_row($rs);
$result["total"] = $row[0]; $rs = mysql_query("select * from listy order by $sort $order limit $offset,$rows"); $items = array(); while($row = mysql_fetch_object($rs)){ array_push($items, $row); } $result["rows"] = $items; echo json_encode($result);
I tried some things and non worked
Title: Re: Set a other default value for pagination ( not 10 -> 50 )
Post by: jarry on July 29, 2014, 05:12:47 PM
The pager of datagrid has 'pagePosition','pageNumber','pageSize' and 'pageList' properties. You must set them correctly before loading data. $('#dg').datagrid({ pageSize: 50, pageList: [10,20,30,40,50], //... });
|