2011-09-16 4 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, 이름과 이메일 초기화와 JSON 형식의 데이터를 반환해야

+0

무엇을 'connectextjs.php'가 반환합니까? –

답변

0

connectextjs.php. 나 머밍 협약은 엄격하게 준수되어야한다.

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); 
    
    } 
    
    }); 
    
관련 문제