Extjs 未在sencha touch中加载存储
我使用下面的代码来存储来自ajax请求的数据,但它没有在存储上装载数据,所以请告诉我我做错了什么 这是我的商店课程:Extjs 未在sencha touch中加载存储,extjs,sencha-touch,Extjs,Sencha Touch,我使用下面的代码来存储来自ajax请求的数据,但它没有在存储上装载数据,所以请告诉我我做错了什么 这是我的商店课程: Ext.define("Por.store.Notes", { extend: "Ext.data.Store", config: { storeId: 'Notes', model: "Por.model.Note", } }); 这是我的模型课: Ext.define("Por.model.Not
Ext.define("Por.store.Notes", {
extend: "Ext.data.Store",
config: {
storeId: 'Notes',
model: "Por.model.Note",
}
});
这是我的模型课:
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' }
],
}
});
这是我正在触发的ajax请求:
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.view.NotesListContainer", {
extend: "Ext.Container",
alias: "widget.noteslistcontainer",
initialize: function () {
this.callParent(arguments);
var notesTitle = {
xtype: 'panel',
html:'<div style = " text-align:center; padding-top:10px;" >First Data</div>'
};
var notesData = {
xtype: 'panel',
html:'<div style = " padding-left:15px;">Personalized Content for ARP</div>'
};
Ext.define(“Por.view.NotesListContainer”{
扩展:“Ext.Container”,
别名:“widget.noteslistcontainer”,
初始化:函数(){
this.callParent(参数);
var notesTitle={
xtype:'面板',
html:“第一个数据”
};
var notesData={
xtype:'面板',
html:“ARP的个性化内容”
};
这是我的列表视图:
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>'
}
});
var notesList={
xtype:“noteslist”,
存储:Ext.getStore(“注释”),
听众:{
itemtap:{fn:this.onNotesListExpose,作用域:this}
}
};
添加([notesTitle,notesData,notesList]);
},
onNewButtonTap:函数(){
console.log(“newNoteCommand”);
this.firevent(“newNoteCommand”,this);
},
OnNotesListExpose:功能(dv、索引、项目、记录){
log(“editNoteCommand”);
this.firevent('editNoteCommand',this,record);
},
配置:{
布局:{
类型:“vbox”
}
}
});
Ext.define(“Por.view.NotesList”{
扩展:“Ext.dataview.List”,
别名:“widget.noteslist”,
配置:{
加载文字:“加载注释…”,
emptyText:“未找到任何便笺。”,
是的,
itemTpl:“{content\u name}类型:{company\u name}”
帐户:
{lookup\u kind\u name}
'
}
});
以下是json数据:
{
"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"
}]
}
{
“数据”:[{
“id”:“56636”,
“内容名称”:“Ray Zor访谈”,
“种类”:“0”,
“公司名称”:“吉列公司”,
“注”:"业务问题d\r\n*协作基础架构不足\r\n*同比增长100%\r\n*由于服务问题导致销售损失\r\n\r\n解决方案\r\n*带Oracle插件的Apollo suite v7\r\n*SQL AppAccelerator\r\n*解决方案咨询业务\r\n\r\n结果\r\n*上市时间流程缩短30%\r\n*客户sat分数提高25%\r\n*更好地利用现有IT员工“,
“attext”:空,
“cid”:空,
“类别”:“倾听”,
“文件扩展名”:“rref”,
“mime_图像”:空,
“ciid”:空,
“城市名称”:空,
“附加”:空,
“神秘的”:“48737f98c5172”,
“url”:空,
“社交网站共享是否正常”:null,
“skey”:空,
“查找id”:“-1”,
“查找种类名称”:“录制音频参考”,
“rid”:“56636”,
“内容”:“wma已加载到此主题”,
“clip_wm”:“48738147342c1.wma”,
“vid_wm”:“,
“闪光剪辑”:“,
“模块数量”:0,
“项目类型”:“侦听”
}]
}
将自动加载:true
放入存储中
或
您尚未为
Por.store.Notes
定义proxy
和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"
}
}
}
});
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"
}
}
}
});