EasyUI Forum

General Category => General Discussion => Topic started by: lucafr on March 09, 2018, 08:31:11 AM



Title: EasyUI 1.5.4.2 pagination
Post by: lucafr 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?


Title: Re: EasyUI 1.5.4.2 pagination
Post by: stworthy 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


Title: Re: EasyUI 1.5.4.2 pagination
Post by: lucafr 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


Title: Re: EasyUI 1.5.4.2 pagination
Post by: lucafr on March 15, 2018, 01:29:14 AM
solved!
in that tutorial this line is missing:
Code:
$offset = ($page-1)*$rows;