I am working with datagrid EasyUI, and I want to do a pagination. In Datagrid displays only 10 row, a shows me 'Displaying 1 to 10 of 10 items'.
I don't know if the output array it's ok, to send to Datagrid.
Here is my code:
public function get_temperatura_humedad_list($page, $rows) {
$offset = ($page - 1) * $rows;
$result = array();
$rs = $this->db->consulta("select count(*) from dht22");
$row = mysqli_fetch_row($rs);
$result['total'] = $row[0];
$rs = $this->db->consulta("select * from dht22 limit $offset, $rows");
$items = array();
while ($row = mysqli_fetch_object($rs)) {
array_push($items, $row);
}
// $result["rows"] = $items;
return $result['rows'] = $items;
}
You should define your variable $rows to get the right offset. Something like this :
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page-1)*$rows;