English 中文(简体)
ExtJs 4, How to prevent xtype: combo fromcolaping when have selected itemslicked?
原标题:ExtJs 4, How to prevent xtype: combo from collapsing when already selected item clicked?

页: 1 当我从扩大名单中点击项目时,ComboBox选择了该项目并崩溃。 如果我点击已经选定的项目,它也会串通一气。

Is there a way to "stop" ComboBox collapsing when user select already selected item?

PS: to be short i want ComboBox to behave like TimeField from http://dev.sencha.com/deploy/ext-4.0.0/examples/themes/index.html

UPDATE

I don t need solutions that dosen t work at least at IE7 and IE8..

最佳回答

If you want that behaviour:

Ext.form.field.ComboBox.override({
    onItemClick: Ext.emptyFn
});
问题回答
var cb = new Ext.form.ComboBox({    
    // here is your local store
    mode:  local ,
    store: new Ext.data.SimpleStore({
        fields: [ id ,  label ],
        data: [
            [ 1 ,  One ],
            [ 2 ,  Two ]
        ]
    }),    
    listeners: {
         beforeselect : function (combo, record, index) {
            // prevent collapsing if the same value is selected
            if (record.data.label == combo.getRawValue()) return false;
        }
    }
});

If it s 3.3 you re dealing with, this seems to work:

Ext.form.ComboBox.override({
  onSelect : Ext.form.ComboBox.prototype.onSelect.createInterceptor(function(record) {
    return this.getValue() !== record.data[this.valueField || this.displayField];
  })
});

Tested on Chrome and IE8. It prevents the onSelect function being called if it the current value exactly matches the value you re trying to set.





相关问题
WPF Datagrid, Setting the background of combox popup

I would like to change the color of the popup background when using a DatagridComboboxColumn in the WPF Toolkit datagrid. I ve edited the Template for a normal Combobox and it works great for selected ...

How to insert ComboBox item into ListBox? [winforms]

The question is very simple, How to insert ComboBox selected item into ListBox using c#? I have tried with this: listbox.Items.Add(combobox.SelectedItem); and some other permutations but it always ...

How do I bind a ComboBox to a one column list

I ve seen how to bind a ComboBox to a list that has columns like this: ItemsSource="{Binding Path=Entries}" DisplayMemberPath="Name" SelectedValuePath="Name" SelectedValue="{Binding Path=Entry}" But ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

热门标签