Witam.
Mam problem z ExtJS. Chciałbym połączyć datagrid z jsonem, ale coś mi nie idzie. Nie sypie błędami, pokazuje tylko nagłówek tabeli. Jest request po dane, w readerze one siedzą prawidłowo, ale nie wyświetla :[
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <title>Test extJS</title>
  5. <script type="text/javascript" src="js/ext-base.js">
  6. </script>
  7. <script type="text/javascript" src="js/ext-all.js">
  8. </script>
  9. <link rel="stylesheet" href="css/ext-all.css">
  10. <link rel="stylesheet" href="css/xtheme-gray.css">
  11. </link>
  12. </head>
  13. <body>
  14. <div id="content" style="width: 1024px; height: 768px;">
  15. </div>
  16. <script type="text/javascript">
  17. var grid;
  18. var ds;
  19.  
  20. Ext.onReady(function(){
  21. init_grid();
  22. });
  23.  
  24. function init_grid(){
  25. ds = new Ext.data.Store({
  26. proxy: new Ext.data.HttpProxy({
  27. url: 'admin/ajax.php?get=users',
  28. method: 'GET'
  29. }),
  30.  
  31. reader: new Ext.data.JsonReader({
  32. root: 'users',
  33. totalProperty: 'total',
  34. id: 'id'
  35. }, ['id', 'login', 'email','registerDate']),
  36. remoteSort: true
  37. });
  38.  
  39. var cm = new Ext.grid.ColumnModel([{
  40. id: 'id',
  41. header: "ID",
  42. dataIndex: 'id',
  43. width: 250
  44. }, {
  45. header: "Login",
  46. dataIndex: 'login',
  47. width: 75
  48. }, {
  49. header: "E-mail",
  50. dataIndex: 'email',
  51. width: 75
  52. }, {
  53. header: "Register Date",
  54. dataIndex: 'registerDate',
  55. width: 100
  56. }]);
  57.  
  58. cm.defaultSortable = true;
  59.  
  60. grid = new Ext.grid.GridPanel({
  61. ds: ds,
  62. cm: cm,
  63. selModel: new Ext.grid.RowSelectionModel({
  64. singleSelect: true
  65. }),
  66. autoExpandColumn: 'id'
  67. });
  68.  
  69. grid.render('content');
  70. ds.load();
  71. }
  72. </script>
  73. </body>
  74. </html>

a tak wygląda json
  1. {"total":2,"users":[{"id":1,"login":"pawel","email":"pawel@ncreations.pl","registerDate":"2008-03-11 06:48:11"},{"id":2,"login":"micha\u0142","email":"michal@wp.pl","registerDate":"2008-03-11 06:48:11"}]}


Pozdrawiam,
Paweł

rozwiązane.... wystarczyło zrobić
  1. grid = new Ext.grid.GridPanel({
  2. ds: ds,
  3. cm: cm,
  4. autoHeight: true, // tutaj była zmiana
  5. selModel: new Ext.grid.RowSelectionModel({
  6. singleSelect: true
  7. }),
  8. autoExpandColumn: 'id'
  9. });