2014-01-21 66 views
0

你可以看到我關於網格的代碼。 在這裏,窗口打開,但我的網格中沒有任何值。 你能幫忙嗎?Extjs商店不填補網格線

我的PHP返回JSON編碼的打擊:

{"results":3,"disPath":"","success":"true","rows":[{"id":"1","faz":"Faz1"},{"id":"2","faz":"Faz2"},{"id":"3","faz":"Faz3"}]} 

代碼

Ext.define('MyDesktop.GridFazlar', { 
    extend: 'Ext.ux.desktop.Module', 

requires: [ 
    'Ext.data.ArrayStore', 
    'Ext.util.Format', 
    'Ext.grid.Panel', 
    'Ext.grid.RowNumberer' 
], 

id:'grid-fazlar', 

init : function(){ 
    this.launcher = { 
     text: 'Fazlar', 
     iconCls:'icon-grid' 
    }; 
}, 



createWindow : function(){ 
    var desktop = this.app.getDesktop(); 
    var win = desktop.getWindow('grid-fazlar'); 
    if(!win){ 

     var fazlarGridStore = new Ext.data.JsonStore({ 
      root: 'rows', 
      autoLoad: true, 
      totalProperty: 'results', 
      remoteSort: true, 
      proxy: new Ext.data.HttpProxy({ 
       url: 'phps/gridPhasesLoader.php', 
       actionMethods: { 
        create : 'POST', 
        read : 'POST', 
        update : 'POST', 
        destroy: 'POST' 
       }, 
      }), 
      baseParams:{ 
       depth: '2', 
       parentId: '2', 
       proccess: 'callGrid', 
      }, 
      fields: [{ 
       name :'id' 
      },{ 
       name :'faz' 
      }, 
      //{ 
      ] 
     }); 

     win = desktop.createWindow({ 
      id: 'grid-fazlar', 
      title:'Fazlar', 
      width:740, 
      height:480, 
      iconCls: 'icon-grid', 
      animCollapse:false, 
      constrainHeader:true, 
      layout: 'fit', 
      listeners:{ 
       beforeshow: function(){ 
          fazlarGridStore.proxy.extraParams = { 
           depth: '2', 
           parentId: '2', 
           proccess: 'callGrid', 
          }; 
       }    
      }, 
      items: [ 
       { 
        border: false, 
        xtype: 'grid', 
        listeners: { 
         celldblclick : function() { 
          alert('Deneme');  

         }, 

        }, 


        contextMenu: new Ext.menu.Menu({ 
         items:[ 
          { 
          id:'grid-fazlar_menu_denemebutton', 
          text: 'DenemeButonu', 
          listeners: { 
           click: function(){ 
            alert('sssss'); 
           } 
          } 


          } 
         ] 
        }), 
        store:fazlarGridStore, 
        columns: [ 
         new Ext.grid.RowNumberer(), 
         { 
          text: "ID", 
          //flex: 1, 
          width: 70, 
          sortable: true, 
          dataIndex: 'id' 
         },{ 
          text: "Faz", 
          //flex: 1, 
          width: 70, 
          sortable: true, 
          dataIndex: 'faz' 
         }, 
               ] 
       } 
      ], 
      tbar:[{ 
       text:'Add Something', 
       tooltip:'Add a new row', 
       iconCls:'add' 
      }, '-', { 
       text:'Options', 
       tooltip:'Modify options', 
       iconCls:'option' 
      },'-',{ 
       text:'Remove Something', 
       tooltip:'Remove the selected item', 
       iconCls:'remove' 
      }] 
     }); 
    } 
    return win; 
}, 

statics: { 
    getDummyData: function() { 
     return [ 
      ['Faz1','06/06/2011','15/08/2010','19/12/2010'], 
      ['Faz2','01/10/2010','15/11/2010','29/11/2011'], 
      ['Faz3','16/11/2010','16/12/2010','14/02/2011'], 
      ['Faz4','19/03/2011','20/03/2011','18/06/2011'], 
      ['Faz5','21/03/2011','20/05/2011','18/08/2011'], 
      ['Faz6','21/05/2011','05/07/2011','18/09/2011'], 
      ['Faz7','06/07/2011','04/09/2011','06/12/2011'], 
      ['Faz8','30/09/2011','30/10/2011','29/12/2011'], 

     ]; 
    } 
} 
}); 

回答

0

您的JSON有一個自定義根:'rows'。您必須配置您的數據讀取器以考慮到這一點:

proxy: { 
    type: 'ajax', 
    url: 'phps/gridPhasesLoader.php', 
    actionMethods: { 
     create : 'POST', 
     read : 'POST', 
     update : 'POST', 
     destroy: 'POST' 
    }, 
    reader: { 
     type: 'json', 
     root: 'rows' 
    } 
}, 
+0

非常感謝,您的解決方案解決了我的問題。 – user3199533