PDA

View Full Version : Ext.form.MultiComboBox



RouslanZenetl
27 Jan 2009, 11:17 AM
Here's my take on a simple multi-select combobox. Tested with Ext 2.2:


Ext.form.MultiComboBox = Ext.extend(Ext.form.ComboBox, {
sep: ', ',
onSelect: function(record, index) {
if (this.fireEvent('beforeselect', this, record, index) !== false) {
var values = this.getValue().split(this.sep);
var selected_value = record.data[this.valueField || this.displayField];
if (selected_value === this.emptyText) values = [this.emptyText];
var i = values.indexOf(selected_value);
if (i<0) {
if (values.length<1||values[0]==='') {
values[0] = selected_value;
} else {
values.push(selected_value)
}
} else {
values.splice(i,1);
}
this.setValue(values.sort().join(this.sep))
this.fireEvent('select', this, record, index);
}
}
});
Ext.reg('multicombo', Ext.form.MultiComboBox);

galdaka
27 Jan 2009, 11:55 PM
Live example or screenshot?

Or simple example for put in ext distribution folder?

Greetings,

RouslanZenetl
29 Jan 2009, 6:58 AM
attached.

simply download, unzip and open index.html either via a web server of any kind or directly in the browser (dismiss usual javascript warnings if any).

enjoy!
z

galdaka
29 Jan 2009, 7:30 AM
Added: http://www.jadacosta.es/extjs/examples/multicombo/

I prefer lovcombo: http://lovcombo.extjs.eu/

Thanks in advance,