2015-01-05 5 views
0

내 JSON 데이터 내가 내가 아약스 response.how에서 얻을 JSON 데이터 저놈 JSON 데이터를 필요로하는 페이징 .FOR를 사용하기 위하여려고하고이로드 데이터는

// 
//var data = { 
//  
// 
//  
//  
//  "success": true, 
//  "users": [ 
//   {"id": 1, "name": 'Ed', "email": "[email protected]"}, 
//   {"id": 2, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 3, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 4, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 5, "name": 'Tommy', "email": "[email protected]"}, 
//  
//   {"id": 11, "name": 'Ed', "email": "[email protected]"}, 
//   {"id": 12, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 13, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 14, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 15, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   
//    {"id": 21, "name": 'Ed', "email": "[email protected]"}, 
//   {"id": 22, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 23, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 24, "name": 'Tommy', "email": "[email protected]"}, 
//   
//   {"id": 25, "name": 'Tommy', "email": "[email protected]"}, 
//  
//   
//  ] 
// }  
//   







// this my store in extjs 


var store = Ext.create('Ext.data.Store', { 
    model: 'AM.model.User', 
     pageSize : 10, 

     autoLoad: true, 
     data:data, 

     proxy: { 
      type: 'memory', 

      enablePaging: true, 
      reader: { 
       type: 'json', 
       root: 'users', 
       totalProperty : 'total' 
      } 
     }, 








    }); 

// ajax request to call json data in json file 

Ext.Ajax.request({ 
     url: 'app/data/users.json', 

     success: function(response, opts) { 
      var obj = response.responseText; 


      store.loadData(resp.responseText, true); 

     }, 
     failure: function(response, opts) { 
      console.log('server-side failure with status code ' + response.status); 
     } 
    }); 



// this is my view . 

Ext.define('AM.view.user.List' ,{ 
    extend: 'Ext.grid.Panel', 
    alias: 'widget.userlist', 

    title: 'All Users', 





    initComponent: function() { 

     Ext.create('Ext.grid.Panel', { 
      title: 'Column Demo', 
      store:store, 
      columns: [ 
     {header: 'ID', dataIndex:'id',flex:1}, 
       {header: 'Name', dataIndex:'name',flex:1}, 
       {text: 'Email', dataIndex:'email',flex:1}, 

      ], 

     renderTo:'example-grid', 
     width: 350, 
     height: 285, 
     dockedItems: [{ 
      xtype: 'pagingtoolbar', 
      store: store, // same store GridPanel is using 
      dock: 'bottom', 
      pageSize: 10, 
      prependButtons: true, 
      displayInfo: true 
     }], 






      renderTo: Ext.getBody() 
     }); 


     store.loadPage(1); 
     this.callParent(arguments); 
    } 



}); 

처럼 ajax 응답 json 데이터를 메모리로로드한다. 아무도 나를 도울 수 있습니까? . 올바른 방법 또는 잘못된 방법으로 가고있다. 아무도 도와 줄 수 없다.

+0

가능한 중복 [extjs의 메모리에 아약스 응답을로드하는 방법] (http://stackoverflow.com/questions/27762528/how-to-load-ajax-response-in-memory-in-extjs) -1 – sra

+0

그 질문에 대한 답변을 얻지 못했습니다. –

+0

같은 질문을 두 번 게시하는 이유는 아닙니다. 귀하의 질문을 리펙토링하려고 시도하십시오. – sra

답변

0

resp.responseText는 일반 문자열을 반환한다. 대신 JSON.parse (resp.responseText)를 사용하십시오.