EasyUI Forum
April 18, 2024, 04:08:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: EasyUI 1.5.4.2 pagination  (Read 5833 times)
lucafr
Newbie
*
Posts: 3


View Profile
« on: March 09, 2018, 08:31:11 AM »

Hi all
I'm using this demo https://www.jeasyui.com/demo/main/index.php CRUD DataGrid with this code

Code:
$sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'sigla';
$order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
$where = "sigla like '%$_REQUEST[sigla]%'";

    $db_con = new PDO("mysql:host={$db_host};dbname={$db_name}",$db_user,$db_pass);
    $db_con -> exec('SET CHARACTER SET utf8');
    $db_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        try {                   
        $q = "select * from items  where " . $where . " order by $sort $order";
        $sql = $db_con->prepare($q);
        $sql->execute();
        $rows = $sql->fetchAll(PDO::FETCH_ASSOC);
        echo json_encode($rows);
        }
        catch(PDOException $e)
        {   
          echo $e->getMessage();
        }

but table show all 25 rows founded in db although pagination at bottom work correctly
Page 1 of 3 Displaying 1 to 10 of 25 items

Of course in table grid I have set pagination="true"

The version is the last one 1.5.4.2

Any help please?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 10, 2018, 03:59:59 AM »

You should retrieve the 'page' and 'rows' parameters from your server and return only the current page rows instead of all rows. Please refer to this tutorial https://www.jeasyui.com/tutorial/datagrid/datagrid2.php
Logged
lucafr
Newbie
*
Posts: 3


View Profile
« Reply #2 on: March 14, 2018, 01:41:28 AM »

Sorry but in this tutorial I dont understand the origin of value of $offset... With that code I have  error on query

select * from mytable where id like '%%' and cod like '%%'  order by emesso asc limit , 10
Logged
lucafr
Newbie
*
Posts: 3


View Profile
« Reply #3 on: March 15, 2018, 01:29:14 AM »

solved!
in that tutorial this line is missing:
Code:
$offset = ($page-1)*$rows;
« Last Edit: March 15, 2018, 03:54:51 AM by lucafr » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!