【发布时间】:2012-04-23 20:47:15
【问题描述】:
这两天我一直在摆弄几行代码,但由于某种原因,我无法让它运行。
我想要什么:
用户从组合框中选择一个关系,随后必须从由第一个组合框过滤的人员列表中选择一个人。如果只有一个人,必须直接选择。如果它有多个,我希望组合框展开并显示检索到的人员列表。听起来很简单。
onRelationContactSelect() 是当一个人被选中时通常执行的代码。由于手动设置值时不会触发选择事件,我只是手动调用它。我在加载事件的回调中有代码,以确保从服务器检索数据。这是首先展开或选择记录所必需的。
问题:
当我有一个记录(records.length == 1)时,一切都像魅力一样。当我有超过 1 条记录时,组合框 contactCombo 无法展开。我通过 ExtJs 内部代码调试了很多,原因是没有焦点。无论我如何尝试调用contactCombo.focus(),它都会 聚焦。因此它不会扩展。为了让它更烦人,我可以使用以下代码扩展另一个组合框:
function onRelationContactSelect() {
categorieStore.load({ callback: function(r, options, success) {
//debugger;
//categorieCombo.focus();
//categorieCombo.expand();
}});
categorieCombo.focus();
categorieCombo.expand();
}
可以看出,我在回调的外部调用了 focus() 和 expand(),但 categorieStore 的模式是“本地”。 categorieStore 中的数据是静态的,但仍从服务器检索。
代码:
function onRelatieSelect() {
contactStore.baseParams = {"relatieId": relatieCombo.value };
contactStore.load({callback: function(records, options, success) {
if(records.length == 1) {
contactCombo.setValue(records[0].get('Id'));
onRelationContactSelect();
} else {
contactCombo.clearValue();
contactCombo.focus();
contactCombo.expand();
}
}});
openTicketRelationLabel.show();
gridTicketRelatie.show();
ticketRelatieStore.load({ params: {relatieId:relatieCombo.value}});
SetRelatieInfo();
SetContractsInfo();
setSfHoursOsab();
showRelationNotifications(relatieCombo.value);
}
我已经尝试了很长时间,但似乎我根本无法从回调处理程序内部和回调处理程序外部聚焦组合框,我还没有数据。
谁能帮帮我?
【问题讨论】:
标签: extjs combobox callback focus jsonstore