2011-09-16 8 views
0

は、私は、MySQLでの簡単なデータを持っているとExtJSのグリッドにそのデータを移入したいExtJSのグリッドのためのJSONをバインドする方法を

私のコード私の問題は、私は、データをロードすることはできませんです

 

Ext.onReady(function(){ 

    var proxy=new Ext.data.HttpProxy( {url:'connectextjs.php'}); 

      var reader=new Ext.data.JsonReader(
      [ 
       {name: 'Employee_ID', mapping: 'Employee_ID'}, 
       {name: 'Department_ID'},   
       {name: 'Name'}, 
       {name: 'Email'}, 

      ] 
     ) 

     var store = new Ext.data.Store( { 
      proxy:proxy, 
      reader:reader 
     }); 

    store.load(); 


    // create the grid 
    var grid = new Ext.grid.GridPanel({ 
     store: store, 
     columns: [ 
      {header: "Employee_ID", width: 90, dataIndex: 'Employee_ID', sortable: true}, 
      {header: "Department_ID", width: 90, dataIndex: 'Department_ID', sortable: true}, 
      {header: "Name", width: 90, dataIndex: 'Name', sortable: true}, 
      {header: "Email", width: 200, dataIndex: 'Email', sortable: true}, 

     ], 
     renderTo:'example-grid', 
     width:540, 
     height:200 
    }); 

}); 

グリッド上に表示されます。私は新しいExtJSの

おかげで午前私を助けてくださいEMPLOYEE_ID、Deaprtment_ID、名前や電子メールのinitでJSONフォーマットされたデータを返す必要があり

+0

何'connectextjs.php'が戻りますか? –

答えて

0

connectextjs.php。 Namming Conventionは厳密に従わなければならない。

0

この方法を使用してグリッドのデータを設定できます。

  1. まず、このように、あなたのグリッドにIDを割り当てます。

    itemId : 'myGrid'; 
    
  2. JSONはこのように、あなたのJSON呼び出しからロードされます:

    Ext.Ajax.request({ 
    url : 'connectextjs.php', 
    
    params : { 
    
    yourParam : 'yourParameters' 
    
    }, 
    
    // --> success simply means your action has no errors 
    
    success : function (conn, response, options, eOpts){ 
    
        var jsonResults = Ext.JSON.decode(conn.responseText); 
    
    
        // --> Now that you have your JsonResults Its time to set it to your grid 
        me.getView().down('#myGrid').setStore(jsonResults); 
    
    } 
    
    });