Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V  < 1 2  
Reply to this topicStart new topic
> [AJAX][MySQL][PHP]jqGrid sortowanie polskich znaków
cent4
post 4.02.2011, 11:56:47
Post #21





Grupa: Zarejestrowani
Postów: 415
Pomógł: 0
Dołączył: 24.12.2008

Ostrzeżenie: (10%)
X----


OK :-).
Cieszę się.
A jakaś podpowiedź odnośnie wylistowanego pliku php i prawidłowego działania filtra?
Go to the top of the page
+Quote Post
nospor
post 4.02.2011, 11:58:03
Post #22





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Podpowiedź dostałeś w przedostatnim poście. No dobrze, zacytuję ci ją, byś nie musiał szukac
Cytat
u nich w przykładach masz wyszukiwanie. Poprostu przejrzyj ich przykłady, które w nazwie mają "search"
smile.gif


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
cent4
post 4.02.2011, 12:23:37
Post #23





Grupa: Zarejestrowani
Postów: 415
Pomógł: 0
Dołączył: 24.12.2008

Ostrzeżenie: (10%)
X----


Czyli muszę szukać :-(. To trochę mi zajmie...
Go to the top of the page
+Quote Post
nospor
post 4.02.2011, 12:30:21
Post #24





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




http://trirand.com/blog/jqgrid/jqgrid.html
Znalezienie na tej liście przykładów ze słowem "search" w nazwie to dwie minuty roboty.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
cent4
post 9.02.2011, 10:30:01
Post #25





Grupa: Zarejestrowani
Postów: 415
Pomógł: 0
Dołączył: 24.12.2008

Ostrzeżenie: (10%)
X----


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:
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <title>jqGrid Demo</title>
  5. <link type="text/css" href="css/ui.jqgrid.css" rel="stylesheet" />
  6. <link type="text/css" href="css/jquery-ui-1.8.9.custom.css" rel="stylesheet" />
  7. <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
  8. <script type="text/javascript" src="js/jquery-ui-1.8.9.custom.min.js"></script>
  9. <script type="text/javascript" src="js/i18n/grid.locale-en.js"></script>
  10. <script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>
  11.  
  12. <script type="text/javascript">
  13. jQuery('document').ready(function() {
  14. jQuery("#users").jqGrid({
  15. url:'example.php',
  16. datatype: "json",
  17. height: 255,
  18. width: 600,
  19. colNames:['ID','Name', 'Code','Opis'],
  20. colModel:[
  21. {name:'id',index:'id', width:65, sorttype:'int'},
  22. {name:'name',index:'name', width:150},
  23. {name:'code',index:'code', width:100},
  24. {name:'opis',index:'opis', width:100}
  25. ],
  26. rowNum:50,
  27. rowTotal: 2000,
  28. rowList : [20,30,50],
  29. //loadonce:true,
  30. mtype: "GET",
  31. rownumbers: true,
  32. rownumWidth: 40,
  33. gridview: true,
  34. pager: '#usersPage',
  35. sortinvid: 'id',
  36. viewrecords: true,
  37. sortorder: "asc",
  38. caption: "Toolbar Searching"
  39. });
  40. jQuery("#users").jqGrid('navGrid','#ptoolbar',{del:false,add:false,edit:false,search:false});
  41. jQuery("#users").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true});
  42. });
  43. </script>
  44.  
  45.  
  46. </head>
  47. <body>
  48. <script type="text/javascript" src="users.js"></script>
  49. <h2>jqGrid Example</h2>
  50. <!--Your grid will be diplayed here-->
  51. <table id="users"></table>
  52. <div id="usersPage"></div>
  53. <!--End of grid-->
  54. </center>
  55. </body>
  56. </html>


a to mój php:
  1. <?php
  2.  
  3. include("dbconfig.php");
  4. // initialization
  5.  
  6. $page = $_GET['page']; // get the requested page
  7. $limit = $_GET['rows']; // get how many rows we want to have into the grid
  8. $sidx = $_GET['sidx']; // get index row - i.e. user click to sort
  9. $sord = $_GET['sord']; // get the direction
  10. if(!$sidx) {
  11. $sidx = 1;
  12. }
  13.  
  14. $totalrows = isset($_GET['totalrows']) ? $_GET['totalrows']: false;
  15. if($totalrows) {
  16. $limit = $totalrows;
  17. }
  18. // connect to the database
  19. $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());
  20. mysql_select_db($database) or die("Database connection error.");
  21.  
  22. mysql_set_charset('utf8',$db);
  23.  
  24. // get the count of rows
  25. /*$result = mysql_query("SELECT COUNT(*) AS count FROM users");
  26. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  27. $count = $row['count'];
  28. // get the required variables
  29. if( $count>0 ) {
  30. $total_pages = ceil($count / $limit);
  31. } else {
  32. $total_pages = 0;
  33. }
  34. if ($page> $total_pages) {
  35. $page = $total_pages;
  36. }
  37. */
  38. if ($limit <0) {
  39. $limit = 0;
  40. }
  41. $start = $limit * $page - $limit;
  42. if ($start <0) {
  43. $start = 0;
  44. }
  45. // get the actual stuff to be displayed in the grid
  46. $SQL = "SELECT * FROM users ORDER BY $sidx $sord LIMIT $start , $limit";
  47. $result = mysql_query($SQL) or die("Could not execute query." . mysql_error());
  48.  
  49.  
  50. // create a response array from the obtained result
  51. $response->page = $page;
  52. $response->total = $total_pages;
  53. $response->records = $count;
  54. $i = 0;
  55. while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  56. $response->rows[$i]['id'] = $row['id'];
  57. $response->rows[$i]['cell'] = array($row['id'],$row['name'],$row['code'],$row['opis']);
  58. $i++;
  59. }
  60. // convert the response into JSON representation
  61. echo json_encode($response);
  62. // close the database connection
  63.  
  64. ?>



I jak tam?
Ma ktoś jakiś pomysł?
Go to the top of the page
+Quote Post

2 Stron V  < 1 2
Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 22.06.2025 - 15:35