View Full Version : How to remove a value from a comboBox after it has been selected?

10 Aug 2007, 2:02 AM
Hi All,

I have a comboBox which displays a list of clients. After a client has been selected, I want to remove it from the comboBox itself so the user can't select it more than once... I got as far as removing the record for the selected client from the store that populates the combo, but I could not find a way to refresh the contents of the combo with the new data (i.e. without the selected client). An option would be to reload the data from the server without the client, but I want to avoid going back to the server for this.

Any suggestions or alternatives on how to implement this functionality?

Thanks as ever,

var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: baseDomain+"/Dataset2Xml"}),
baseParams: {dataSet : "webTree",
columns : "cod_cliente,cognome_nome_codice",
distinct : "true",
orderby : "cognome_nome_codice",
byAgent : "true"
reader: new Ext.data.XmlReader({record: "row",
id: "id"},

var combo = new Ext.form.ComboBox({
fieldLabel : "Cliente",
name : "cliente",
store : store,
valueField : "cod_cliente",
displayField : "cognome_nome_codice",
typeAhead : true,
mode : "local",
loadingText : "Caricamento clienti...",
triggerAction : "all",
emptyText : "Selezioni un cliente...",
maxHeight : 200,
selectOnFocus : true,
listWidth : 400


addClientToTree(treeIntestatario, 'I');
addClientToTree(treeCondiviso, 'V');
addClientToTree(treeProcuratore, 'P');


function addClientToTree(tree,ruolo){

var codiceCliente = combo.getValue();

// SNIP...

if(codiceCliente == r.get("cod_cliente")){
// The record is now removed from the store. How to update the combo???


10 Aug 2007, 3:24 AM
Simply remove it from store (in select event).

10 Aug 2007, 4:06 AM
Thanks for your reply, but that's what I do already and the combo does not refresh its content. The function addClientToTree is called on the "select" event of the combo.... am I missing anything from your reply?

Thanks again

25 Sep 2007, 9:53 PM
combo.store = sto;
combo.view.store = sto;
sto is a new store ;
i hope this can help you