francescoNemesi
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,
Francesco
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"},
["cod_cliente","cognome_nome_codice"])
});
store.load();
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
});
combo.on('select',function(){
addClientToTree(treeIntestatario, 'I');
addClientToTree(treeCoIntestatario,'T');
addClientToTree(treeCondiviso, 'V');
addClientToTree(treeProcuratore, 'P');
});
function addClientToTree(tree,ruolo){
var codiceCliente = combo.getValue();
// SNIP...
store.each(function(r){
if(codiceCliente == r.get("cod_cliente")){
store.remove(r);
// The record is now removed from the store. How to update the combo???
}
})
}
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,
Francesco
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"},
["cod_cliente","cognome_nome_codice"])
});
store.load();
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
});
combo.on('select',function(){
addClientToTree(treeIntestatario, 'I');
addClientToTree(treeCoIntestatario,'T');
addClientToTree(treeCondiviso, 'V');
addClientToTree(treeProcuratore, 'P');
});
function addClientToTree(tree,ruolo){
var codiceCliente = combo.getValue();
// SNIP...
store.each(function(r){
if(codiceCliente == r.get("cod_cliente")){
store.remove(r);
// The record is now removed from the store. How to update the combo???
}
})
}