2013-03-22 134 views
2

我有一个GXT ComboBox这是绑定到ListStore并有一个addSelectionHandler被称为哪些工作正常。我也使用了combo.setEmptyText("Select an item..")GXT ComboBox选择后取消选择

但是,当用户进行选择时,我想让ComboBox返回到其“no selection”状态。我怎样才能让它显示“选择一个项目..”?

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 --- 
    } 

}); 
+0

您是否在您的选择处理程序中尝试了'combo.setValue(null)'? – 2013-03-22 17:58:51

+0

我发现有一个combo.reset(),但没有运气。我会在几天后重新访问时尝试一下您的建议。 – ZimSystem 2013-03-23 14:37:19

+0

无法使用.setValue(null)。我也试过.clear(),.redraw()和这些的各种组合,但没有运气。 – ZimSystem 2013-03-25 16:04:37

回答

2

这似乎在说明目前在GXT 3解决此问题的一个错误,因为报道http://www.sencha.com/forum/showthread.php?234736,存在GXT 3.0.4的。就像那个bug报告的那样,看起来你可以先打电话setValue(null),然后redraw(true)然后setText(null)在场上。

这也发生在其他一些领域 - 基于报告的细节,它似乎很可能是该错误在TriggerField本身,所以此解决方法可能是所有子类都需要的。