extjs4组合框更改还更改另一个组合框数据存储,并选择值
这可能是一个愚蠢的问题,但我想问当组合框选定值更改时是否有可能更改另一个组合框的存储数据。
这可能会令人困惑,所以让我举一个清楚的例子,...
组合框A有一个包含国家/地区名称的数据存储 comboboxB 有一个包含城市名称的数据存储
,因此,comboboxA
中的数据可能是:
- USA - Mexico - England
当 comboboxA
的值为“USA”将是:
- Texas - New York - Washington
但是当组合框A的值为“英格兰”时,组合框B中的数据将是:
- London - Manchester
我该怎么做?
我尝试过:
comboboxA.on("change", function(cb, newValue, oldValue){
if(newValue == "USA"){
comboboxB.store.loadData(["Texas", "New York", "Washington"]);
comboboxB.setValue("Texas");
}
else if(newValue == "England"){
comboboxB.store.loadData(["London", "Manchester"]);
comboboxB.setValue("London");
}
});
我的代码有问题吗?
This might be a silly question, but I want to ask if there is a possibility to change another combobox's store data when a combobox selected value is changed.
It might be confusing, so let me give a clear example,...
comboboxA has a datastore that contains of country's name
comboboxB has a datastore that contains of city's name
so, the data in comboboxA
could be:
- USA - Mexico - England
And the data incomboboxB
when the value of comboboxA
is "USA" would be:
- Texas - New York - Washington
but when the value of comboboxA is "England", the data in comboboxB would be:
- London - Manchester
How could I do that?
I've try:
comboboxA.on("change", function(cb, newValue, oldValue){
if(newValue == "USA"){
comboboxB.store.loadData(["Texas", "New York", "Washington"]);
comboboxB.setValue("Texas");
}
else if(newValue == "England"){
comboboxB.store.loadData(["London", "Manchester"]);
comboboxB.setValue("London");
}
});
Is there something wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅更新后的Combobox FAQ。您必须使用 select 事件的侦听器。请参阅“链接组合框”中的示例
See the updated Combobox FAQ. You must use the listeners for the select event. See the example in "linked comboBoxes"
您的数据应采用以下形式:
组合框B 的存储应具有以下字段:
但您没有说明错误是什么,所以我只能猜测这是否可能是您的问题。您应该提供有关问题所在以及问题如何出现的更多详细信息。
Your data should be of the form:
And the store for comboboxB should have fields like:
But you did not say what the error was, so I can just guess if this could be your problem. You should come up with more details about what the problem is and how it shows up.