PDA

View Full Version : ComboBox - TextField methods don't work



DarekKay
29 Nov 2011, 3:31 AM
Simple example:

public void onModuleLoad()
{
ModelKeyProvider<Stock> keyProvider = new ModelKeyProvider<Stock>()
{
@Override
public String getKey(Stock item)
{
return item.getKey();
}
};

LabelProvider<Stock> labelProvider = new LabelProvider<Stock>()
{
@Override
public String getLabel(Stock item)
{
return item.getName();
}
};

ListStore<Stock> store = new ListStore<Stock>(keyProvider);
store.add(new Stock("key1", "name1"));
store.add(new Stock("key2", "name2"));
store.add(new Stock("key3", "xname3"));

ComboBox<Stock> cb = new ComboBox<Stock>(store, labelProvider);
cb.setTriggerAction(TriggerAction.ALL);

cb.setEditable(false);
cb.setForceSelection(true);

RootLayoutPanel.get().add(cb);
}

class Stock
{

public Stock(String key, String name)
{
this.key = key;
this.name = name;
}

String key = "";
String name = "";

public String getKey()
{
return key;
}

public void setKey(String key)
{
this.key = key;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

}

Both methods

cb.setEditable(false);
cb.setForceSelection(true);
achieved the desired effect back in GXT2 - you couldn't type your own value and were forced to use a default one. This doesn't seem to work in GXT3 anymore.

Colin Alworth
30 Nov 2011, 3:07 PM
TriggerField.setEditable fix is in SVN, though the setForceSelection issue is still unresolved. Thanks for the report.