2013-01-08 4 views
1

아약스 요청의 데이터를 저장하기 위해 코드 아래에서 사용하고 있지만 저장소에 데이터를 저장하지 않으므로 내가 잘못하고있는 것을 알려주십시오. 이건 내 모델 클래스입니다sencha touch에 저장되지 않음

Ext.define("Por.store.Notes", { 
    extend: "Ext.data.Store", 
     config: { 
    storeId: 'Notes', 
     model: "Por.model.Note", 


    } 
}); 

: 여기

이 내 가게 클래스입니다

  Ext.Ajax.request({ 
      url: url, 
      scope: this, 
     callback: callbackFn 

      success: function(response) { 

       var responseData = Ext.JSON.decode(response.responseText); 
       var store = Ext.getStore('Notes'); 
      store.setData(responseData); 
      store.sync();  

      }, 

    failure:function(response){ 
     alert(response.status); 
    } 
     }); 

이 내 볼 수 있습니다 :

Ext.define("Por.model.Note", { 
    extend: "Ext.data.Model", 
    config: { 
     idProperty: 'id', 
     fields: [ 
      { name: 'id', type: 'string' }, 
      { name: 'content_name', type: 'string' }, 
      { name: 'kind', type: 'string' }, 
      { name: 'company_name', type: 'string' }, 
     { name: 'note', type: 'string' }, 
      { name: 'attext', type: 'string' }, 
      { name: 'cid', type: 'string' }, 
      { name: 'category', type: 'string' }, 
     { name: 'file_extension', type: 'string' }, 
      { name: 'mime_image', type: 'string' }, 
      { name: 'ciid', type: 'string' }, 
      { name: 'citem_name', type: 'string' }, 
     { name: 'attach', type: 'string' }, 
      { name: 'cryptic', type: 'string' }, 
      { name: 'url', type: 'string' }, 
      { name: 'is_socialsites_share_ok', type: 'string' }, 
     { name: 'skey', type: 'string' }, 
      { name: 'lookup_id', type: 'string' }, 
      { name: 'lookup_kind_name', type: 'string' }, 
      { name: 'rid', type: 'string' }, 
     { name: 'content', type: 'string' }, 
      { name: 'clip_wm', type: 'string' }, 
      { name: 'vid_wm', type: 'string' }, 
      { name: 'flash_clip', type: 'string' }, 
     { name: 'module_num', type: 'string' }, 
      { name: 'itemtype', type: 'string' } 
     ], 

    } 
}); 

이것은 내가 발사하고 아약스 요청입니다 :

여기
 var notesList = { 
      xtype: "noteslist", 
      store: Ext.getStore("Notes"), 
      listeners: { 
       itemtap: { fn: this.onNotesListDisclose, scope: this } 
      } 
     }; 

     this.add([notesTitle,notesData, notesList]); 
    }, 
    onNewButtonTap: function() { 
     console.log("newNoteCommand"); 
     this.fireEvent("newNoteCommand", this); 
    }, 
    onNotesListDisclose: function(dv, index, item, record) { 
     console.log("editNoteCommand"); 
     this.fireEvent('editNoteCommand', this, record); 
    }, 
    config: { 
     layout: { 
      type: 'vbox' 
     } 
    } 
}); 

Ext.define("Por.view.NotesList", { 
    extend: "Ext.dataview.List", 
    alias: "widget.noteslist", 
    config: { 
     loadingText: "Loading Notes...", 
     emptyText: "<div class=\"notes-list-empty-text\">No notes found.</div>", 
     onItemTap: true, 
     itemTpl:'<div ><div style="font-size:14px;color: #5090D0;font-weight:bold;">{content_name}</div><div style = 

"clear:both;"></div></div><div><p style="font-size:12px;"> <span style="font-weight:bold;font-size:14px;"><b>Type: </b></span> {company_name} 

</p></div><div><p style="font-size:12px;"><span style="font-weight:bold;font-size:14px;border:1px solid red;">Account: </span> 

{lookup_kind_name} </p></div></div>'   
    } 
}); 

는 JSON 데이터입니다 :

이 (10) 내 목록보기입니다

{ 
"data": [{ 
    "id": "56636", 
    "content_name": "Ray Zor interview", 
    "kind": "0", 
    "company_name": "The Gillette Company", 
    "note": "<b>Business Problem<\/b> d\r\n* Inadequate collaboration infrastructure\r\n* 100% year over year growth\r\n* Lost sales due to service issues \r\n\r\n<b>Solution<\/b>\r\n* Apollo suite v7 with Oracle add-in\r\n* AppAccelerator for SQL\r\n* Solution Consulting engagement\r\n\r\n<b>Results<\/b>\r\n* 30% in time to market process\r\n* 25% improvement in customer sat scores\r\n* Better utilization of existing IT staff", 
    "attext": null, 
    "cid": null, 
    "category": "Listen", 
    "file_extension": "rref", 
    "mime_image": null, 
    "ciid": null, 
    "citem_name": null, 
    "attach": null, 
    "cryptic": "48737f98c5172", 
    "url": null, 
    "is_socialsites_share_ok": null, 
    "skey": null, 
    "lookup_id": "-1", 
    "lookup_kind_name": "Recorded Audio Reference", 
    "rid": "56636", 
    "content": "a wma is loaded to this topic", 
    "clip_wm": "48738147342c1.wma", 
    "vid_wm": "", 
    "flash_clip": "", 
    "module_num": 0, 
    "itemtype": "listen" 
}] 
} 

답변

1

가 어느 가게에서 autoLoad: true을 넣어

또는

store.load({ 
    callback: function(records, operation, success) { 
     // the operation object contains all of the details of the load operation 
     console.log(records); 
    }, 
    scope: this 
}); 
1

당신은이 정의되지 않음 proxyPor.store.Notes에 대해서는 reader입니다. 다음과 같은 구성을 정의하십시오. -

Ext.define("Por.store.Notes", { 
    extend: "Ext.data.Store", 
    config: { 
     storeId: 'Notes', 
     model: "Por.model.Note", 
     proxy: { 
      type: "ajax", 
      url : url, 
      reader: { 
       type: "json", 
       rootProperty: "data" 
      } 
     } 
    }   
}); 
관련 문제