Nie no - to to zajmie nawet parę sekund - cały szkopuł polega na tym, że trzeba wiedzieć co zmienić :-(
Dlaczego przy włączonym: loadonce:true, wszystko z filtrowaniem działa :-(? Wiem, że wtedy filtruje javascript, a nie mysql, ale jak to przestawić żeby filtrował mysql?
już mi ręce opadają :-(
Już na prawdę nie wiem co robić - proszę pomóżcie...
to mój html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link type="text/css" href="css/ui.jqgrid.css" rel="stylesheet" /> <link type="text/css" href="css/jquery-ui-1.8.9.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.9.custom.min.js"></script> <script type="text/javascript" src="js/i18n/grid.locale-en.js"></script> <script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>
<script type="text/javascript"> jQuery('document').ready(function() {
jQuery("#users").jqGrid({
url:'example.php',
datatype: "json",
height: 255,
width: 600,
colNames:['ID','Name', 'Code','Opis'],
colModel:[
{name:'id',index:'id', width:65, sorttype:'int'},
{name:'name',index:'name', width:150},
{name:'code',index:'code', width:100},
{name:'opis',index:'opis', width:100}
],
rowNum:50,
rowTotal: 2000,
rowList : [20,30,50],
//loadonce:true,
mtype: "GET",
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: '#usersPage',
sortinvid: 'id',
viewrecords: true,
sortorder: "asc",
caption: "Toolbar Searching"
});
jQuery("#users").jqGrid('navGrid','#ptoolbar',{del:false,add:false,edit:false,search:false});
jQuery("#users").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true});
});
<!--Your grid will be diplayed here-->
<!--End of grid-->
a to mój php:
<?php
include("dbconfig.php");
// initialization
$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
if(!$sidx) {
$sidx = 1;
}
$totalrows = isset($_GET['totalrows']) ?
$_GET['totalrows']: false; if($totalrows) {
$limit = $totalrows;
}
// connect to the database
mysql_set_charset('utf8',$db);
// get the count of rows
/*$result = mysql_query("SELECT COUNT(*) AS count FROM users");
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$count = $row['count'];
// get the required variables
if( $count>0 ) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page> $total_pages) {
$page = $total_pages;
}
*/
if ($limit <0) {
$limit = 0;
}
$start = $limit * $page - $limit;
if ($start <0) {
$start = 0;
}
// get the actual stuff to be displayed in the grid
$SQL = "SELECT * FROM users ORDER BY $sidx $sord LIMIT $start , $limit";
// create a response array from the obtained result
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$i = 0;
$response->rows[$i]['id'] = $row['id'];
$response->rows[$i]['cell'] = array($row['id'],$row['name'],$row['code'],$row['opis']); $i++;
}
// convert the response into JSON representation
echo json_encode
($response); // close the database connection
?>
I jak tam?
Ma ktoś jakiś pomysł?