witam, mam taki kod:

  1. <!DOCTYPE html>
  2. <title>The Simplest Dojo DataGrid Example of All Time</title>
  3. <link rel="stylesheet" type="text/css"
  4. href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css" />
  5.  
  6. <link rel="stylesheet" type="text/css"
  7. href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/Grid.css" />
  8.  
  9. <link rel="stylesheet" type="text/css"
  10. href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/claroGrid.css" />
  11. </head>
  12.  
  13. <body class="claro">
  14. <div style="width: 600px; height: 200px">
  15. <table id="billsGrid" dojoType="dojox.grid.DataGrid">
  16. <tr>
  17. <th field="number">Number</th>
  18. <th field="name">Name</th>
  19. <th field="position">Position</th>
  20. <th field="victories" width="180px">Super Bowl Victories</th>
  21. </tr>
  22. </thead>
  23. </table>
  24. </div>
  25.  
  26. <script type="text/javascript"
  27. src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.haha.gif.js"
  28. djConfig="parseOnLoad:true"></script>
  29.  
  30. <script type="text/javascript">
  31. dojo.require("dojox.grid.DataGrid");
  32. dojo.require("dojo.data.ItemFileReadStore");
  33.  
  34. <script type="text/javascript">
  35. dojo.ready(function() {
  36. var theGreatestTeamOfAllTime = {
  37. items: [ {
  38. "number":"12",
  39. "name":"Jim Kelly",
  40. "position":"QB",
  41. "victories":"0"
  42. },
  43. {
  44. "number":"34",
  45. "name":"Thurman Thomas",
  46. "position":"RB",
  47. "victories":"0"
  48. },
  49. {
  50. "number":"89",
  51. "name":"Steve Tasker",
  52. "position":"WR",
  53. "victories":"0"
  54. },
  55. {
  56. "number":"78",
  57. "name":"Bruce Smith",
  58. "position":"DE",
  59. "victories":"0"
  60. }
  61. ],
  62. identifier: "number"
  63. };
  64.  
  65. var dataStore =
  66. new dojo.data.ItemFileReadStore(
  67. { data:theGreatestTeamOfAllTime }
  68. );
  69. var grid = dijit.byId("billsGrid");
  70. grid.setStore(dataStore);
  71. });
  72.  
  73. </body>
  74. </html>
  75.  


W jaki sposób zmienić kod aby do grid'a pobierał dane z bazy? Znalazłem jakieś informacje, że za pomocą json ale bez szczegołów. Prosze o pomoc.

ok, poradziłem sobie -> dla zainteresowanych:

  1. $arr = array();
  2.  
  3. $query = "SELECT * FROM json";
  4. $result = mysql_query ($query);
  5. while($row = mysql_fetch_object($result)){
  6. $arr[] = $row;
  7. }
  8. $jsonStr = json_encode($arr);


zmienną $jsonStr wrzucam do:

  1. var theGreatestTeamOfAllTime = {
  2. items: <?php echo json_encode($arr);?>,
  3. identifier: "number"
  4. };