Sencha Touch:将数据存储 json 数据获取到 selectfield
我一直在尝试让我的选择字段显示我的模板数据,但遇到了困难。
我的 TemplateStore 如下所示:
Ext.regModel('tempItems', {
fields: [
{ name: 'Name', type: 'string' }
]
});
Ext.regStore('TempStore', {
model: 'tempItems',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'http://localhost:56132/Service.asmx/GetTemplateModels',
reader: {
type: 'json',
root: 'd'
}
}
});
Selectfield 代码:
xtype: 'selectfield',
name: 'template',
style: 'background-color: inherit; margin-left: 8px',
store: 'TempStore',
displayField: 'Name',
valueField: 'Name'
JSON 返回数据:
"{"d":[{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 1","id":1},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 2","id":2},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 3","id":3},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 4","id":4},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 5","id":5}]}"
任何帮助或指针都会很棒!
我正在上传一个示例项目,在此处显示我的问题: http://www.vbninja.com/SenchaTouchProblem.zip< /a>
谢谢 瑞安
I have been having a rough time trying to get my selectfield to display my template data.
My TemplateStore looks like the following:
Ext.regModel('tempItems', {
fields: [
{ name: 'Name', type: 'string' }
]
});
Ext.regStore('TempStore', {
model: 'tempItems',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'http://localhost:56132/Service.asmx/GetTemplateModels',
reader: {
type: 'json',
root: 'd'
}
}
});
Selectfield code:
xtype: 'selectfield',
name: 'template',
style: 'background-color: inherit; margin-left: 8px',
store: 'TempStore',
displayField: 'Name',
valueField: 'Name'
JSON return data:
"{"d":[{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 1","id":1},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 2","id":2},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 3","id":3},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 4","id":4},{"__type":"SenchaTouchProblem.TemplateModel","Name":"Test 5","id":5}]}"
Any help or pointers would be amazing!
I am uploading a sample project showing my problem here: http://www.vbninja.com/SenchaTouchProblem.zip
Thanks
Ryan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:
检查代码后,发现有几处错误。首先你没有使用json,而是使用xml,所以你的阅读器不正确,然后你在autoload配置选项中有一个拼写错误,它应该是autoLoad(注意大写的L,顺便说一下,这很难检测到:)),无论如何尝试这:
Update:
After checking your code, you have several things wrong. First you are not using json, but xml so your reader is incorrect, and then you have a typo in autoload config option, it should be autoLoad (note the capital L, this was hard to detect by the way :) ), anyway try this: