How do i make a select field to have no solection.
Like right now, the first element in my store is getting selected by default. I tried the reset method but nothing really happened. Is there a way to make sure no option is selected?
How do i make a select field to have no solection.
Like right now, the first element in my store is getting selected by default. I tried the reset method but nothing really happened. Is there a way to make sure no option is selected?
Just ran into this today too. I will post a bug report for this and link back here.
Actually, I am going to let the Admin's determine if this is a bug or not. This is a 'select' field, not a 'combo'. It may be designed to mimic an HTML select field, and if so then it's working as designed.
As on 0.95, you cannot have a select field with no value selected. The 'setValue' method of Field is the reason why (reset() just calls setValue() passing the original value):
If you pass undefined or an empty string that does not match a record in the store, then it will just select the first record in your store.Code:setValue : function(v) { var record = v ? this.store.findRecord(this.valueField, v) : this.store.getAt(0); ....
Having a way to set selection to none would be good.
tfrugia I did not find a bug post. Have you made one?
I did not post a bug. I could be wrong, but this looks like more of a feature request than a bug. A standard html select element must have an item selected at all times, so this 'select' object is behaving normally IMO.
I would prefer this 'feature' so you can use placeHolder as in any formfield.
Well anyway i made a post in the bugs. Hope something is done.
I too would like to see the ability to *not* have a default selection and utilize the placeHolder value. Without it, how to do handle a select field which is optional? And no, adding a default non-selected value to the top of the data store for the select is not very Sencha/ExtJS like.
Totally agree with you. Default selection is wrong behavior for optional fields.
Set the property "value" of the selectfield to ' ' (empty), like this:
The problem for me is to display the placeHolder... it is defined, but is not showing in my form.Code:{ xtype : 'selectfield', displayField : 'name', valueField : 'id', value : ' ', // here placeHolder : 'Select...', store : myStore }
This way, the field doesn't look like a select field and the user may be confuse, so I would like to put a placeHolder. Does anyone know how to do it?