Sencha Touch selectfield 项目选择问题
这是我的模型和商店,
Ext.regModel('Agent', { fields: [{ name: 'userid', type: 'int' }, { name: 'agentname', type: 'string'}] });
App.stores.agentStore = new Ext.data.Store({
model: 'Agent',
storeId: 'AgentsStoreid',
proxy: {
type: 'ajax',
url: 'https://abc123.com/wsbrightdoor.asmx/GetAgents?username=abc&password=123',
reader: { type: 'xml', root: 'root', record: 'salesagent' }
},
autoLoad: true
});
//App.stores.agentStore.load();
console.log(App.stores.agentStore);
我将此商店设置为我的选择项,如下
var sel = new Ext.form.Select(
{
id: 'Myselectfield',
name: 'myagent',
label: 'Agent',
store: App.stores.agentStore,
displayField: 'agentname',
valueFiels: 'userid',
placeHolder: 'Click/touch to select options...',
});
所示这是服务器返回的 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<root>
<salesagent>
<userid>1</userid>
<agentname>Name1</agentname>
</salesagent>
<salesagent>
<userid>13</userid>
<agentname>Name2</agentname>
</salesagent>
</root>
我可以看到商店正在从网络服务器获取值,并且我可以看到带有代理名称和用户 ID 值的数据对象。我们使用 Sencha touch 1.1.0。我现在可以看到选择字段中从 Web 服务填充的值。当我选择一个项目时,所选项目不会更改为我选择的项目。我看到商店中的第一个元素已被选中。我们该如何解决这个问题?请建议。
Here is my Model and Store,
Ext.regModel('Agent', { fields: [{ name: 'userid', type: 'int' }, { name: 'agentname', type: 'string'}] });
App.stores.agentStore = new Ext.data.Store({
model: 'Agent',
storeId: 'AgentsStoreid',
proxy: {
type: 'ajax',
url: 'https://abc123.com/wsbrightdoor.asmx/GetAgents?username=abc&password=123',
reader: { type: 'xml', root: 'root', record: 'salesagent' }
},
autoLoad: true
});
//App.stores.agentStore.load();
console.log(App.stores.agentStore);
I'm setting this store to my selectitem like this
var sel = new Ext.form.Select(
{
id: 'Myselectfield',
name: 'myagent',
label: 'Agent',
store: App.stores.agentStore,
displayField: 'agentname',
valueFiels: 'userid',
placeHolder: 'Click/touch to select options...',
});
Here is my XML file the server returns
<?xml version="1.0" encoding="utf-8"?>
<root>
<salesagent>
<userid>1</userid>
<agentname>Name1</agentname>
</salesagent>
<salesagent>
<userid>13</userid>
<agentname>Name2</agentname>
</salesagent>
</root>
I can see store is getting values from the webserver and I can see the data object with agentname and userid values. We are using Sencha touch 1.1.0. I can now see the values in the selectfield that are populated from the webservice. When I select an item the selected item is not changing to the item I selected. I see the first element in my store as selected. How do we fix this? Please suggest.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Sencha touch 文档非常模糊。本来可以更好地为每个属性和方法提供一些示例来展示如何使用它。这是我解决问题的方法。我必须使用典型的 Jquery Ajax 请求来完成此操作。
在 MainForm.js 中,选择控件如下所示
The Sencha touch documentation is so vague. Could have been better with some examples at every property and method to show how to use it. Here is how I fixed my problem. I have to do it with typical Jquery Ajax request.
and in MainForm.js the select control goes like this