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ą :-(
Dzięki uprzejmości mojego znajomego umieściłem to na: http://www.infocent.pl/!projekty/cent4/myfirstgrid.html
Już na prawdę nie wiem co robić - proszę pomóżcie...
(wcześniej umieściłem mój przykład pod innym tematem ale tamten temat nie dotyczył tego problemu i nikt pewnie na niego nie odpowiedział, bo nie wiedział czego dotyczy...)
to mój html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <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"> 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}); }); </script> </head> <body> <center> <!--Your grid will be diplayed here--> <!--End of grid--> </center> </body> </html>
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; } 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']; $i++; } // convert the response into JSON representation // close the database connection ?>
Uściślając - nie działa filtrowanie - jak wpisuję na górze w okna do edycji co chce, żeby wyświetlił NIE DZIAŁA.
Widzę że, po braku odpowiedzi - problem jest poważny :-(