jQWidgets Forums
Forum Replies Created
-
Author
-
November 18, 2015 at 10:36 pm in reply to: Maximum rows allowed in grid Maximum rows allowed in grid #78317
Dimitar,
I began again to look at the problem I described you before and I found that in my select statement the keyword SQL_CALC_FOUND_ROWS was missing. Thanks,
Axel Cabrera
I
October 11, 2015 at 2:16 am in reply to: Maximum rows allowed in grid Maximum rows allowed in grid #76659Hi,
Dimitar is there a link to the “Virtual Scrolling” link you referred above that shows the data.php and index.php files used in it? I am having problems implemening sample “jqxGrid Virtual Scrolling with PHP and MySQL”. I created both pages as described in the example but substituted the database information for mine. As a result I only get the first 18 rows of the table and the scrolling doesn’t work. Here are my data.php and index.php files:
—– data.php ——-
<?php
$hostname = “localhost”;
$database = “mortalidad”;$username = “root”;
$password = “”;$connect = mysqli_connect($hostname, $username, $password)
or die(‘Could not connect: ‘ . mysqli_error($connect));ini_set(‘memory_limit’, ‘512M’);
mysqli_select_db($connect, $database);$bool = mysqli_select_db($connect, $database);
if ($bool === False){
print “can’t find $database”;
}$firstvisiblerow = $_GET[‘recordstartindex’];
$lastvisiblerow = $_GET[‘recordendindex’];error_log($firstvisiblerow . “- ” . $lastvisiblerow . chr(13), 3, “my-errors.log”);
$rowscount = $lastvisiblerow – $firstvisiblerow;
$query = “SELECT co_pahocode, nu_ano, co_icd10, total FROM tb_mortalidad_g2 “;
$query = $query . ” LIMIT $firstvisiblerow, $rowscount”;$result = mysqli_query($connect, $query) or die(“SQL Error 1: ” . mysqli_error($connect));
$sql = “SELECT FOUND_ROWS() AS
found_rows
;”;
$rows = mysqli_query($connect, $sql);
$rows = mysqli_fetch_assoc($rows);
$total_rows = $rows[‘found_rows’];
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$orders[] = array(
‘co_pahocode’ => $row[‘co_pahocode’],
‘nu_ano’ => $row[‘nu_ano’],
‘co_icd10’ => $row[‘co_icd10’],
‘total’ => $row[‘total’]
);
}
$data[] = array(
‘TotalRows’ => $total_rows,
‘Rows’ => $orders
);echo json_encode($data);
—- index.php —————–
<!DOCTYPE html>
<html lang=”en”>
<head>
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.classic.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxmenu.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdata.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxgrid.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxgrid.selection.js”></script>
<script type=”text/javascript”>
$(document).ready(function () {
// prepare the data
var source =
{
url: ‘data.php’,
dataType: ‘json’,
cache: false,
datafields: [
{ name: ‘co_pahocode’ },
{ name: ‘nu_ano’ },
{ name: ‘co_icd10’ },
{ name: ‘total’ }
],
root: ‘Rows’,
beforeprocessing: function (data) {
source.totalrecords = data[0].TotalRows;
}
};
var dataAdapter = new $.jqx.dataAdapter(source);$(“#jqxgrid”).jqxGrid(
{
source: source,
theme: ‘classic’,
virtualmode: true,
width:”100%”,
height:”1000px”,rendergridrows: function(obj)
{
return obj.data;
},
columns: [
{ text: ‘Country’, datafield: ‘co_pahocode’, width: 200 },
{ text: ‘Year’, datafield: ‘nu_ano’, cellsformat: ‘d’, width: 200 },
{ text: ‘Cause’, datafield: ‘co_icd10’, width: 200 },
{ text: ‘Total’, datafield: ‘total’, width: 180 }
]
});
});
</script>
</head>
<body class=’default’>
<div id=”jqxgrid”></div>
</body>
</html>—————–
Thanks,
Axel Cabrera -
AuthorPosts