我有一个 GXT ComboBox
,它绑定(bind)到 ListStore
并有一个被调用的 addSelectionHandler
,它工作正常。我还使用了 combo.setEmptyText("Select an item..")
.
但是,当用户进行选择时,我希望 ComboBox 返回到其“无选择”状态。我怎样才能让它返回以显示“选择一个项目..”?
StProperties props = GWT.create(StProperties.class);
ListStore<St> sts = new ListStore<St>(combo.id());
combo = new ComboBox<St>(sts, props.name());
combo.setTypeAhead(true);
combo.setTriggerAction(TriggerAction.ALL);
addHandlersForEventObservation(combo,props.name());
...
combo.addSelectionHandler(new SelectionHandler<T>() {
public void onSelection(SelectionEvent<T> event) {
System.out.println("value selected:"+event.getSelectedItem());
// handle selection
// unselect item in combo here ---
}
});
最佳答案
目前 GXT 3 中似乎存在围绕此问题的错误,如 http://www.sencha.com/forum/showthread.php?234736 中报告的那样。 ,从 GXT 3.0.4 开始存在。正如该错误中所报告的,您似乎可以先调用 setValue(null)
,然后调用 redraw(true)
,然后调用 setText(null)
在球场上。
这也发生在其他一些字段上 - 根据报告的详细信息,该错误似乎可能存在于 TriggerField
本身中,因此所有子类可能都需要此解决方法。
关于gwt - GXT ComboBox 选择后取消选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15575629/