1. #1
    Sencha User blessan's Avatar
    Join Date
    May 2010
    Posts
    316
    Vote Rating
    1
    blessan is on a distinguished road

      0  

    Default Select field to no selection.

    Select field to no selection.


    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?

  2. #2
    Touch Premium Member
    Join Date
    Dec 2007
    Posts
    109
    Vote Rating
    1
    tfrugia is on a distinguished road

      0  

    Default


    Just ran into this today too. I will post a bug report for this and link back here.

  3. #3
    Touch Premium Member
    Join Date
    Dec 2007
    Posts
    109
    Vote Rating
    1
    tfrugia is on a distinguished road

      0  

    Default


    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):

    Code:
    setValue : function(v) {
    	var record = v ? this.store.findRecord(this.valueField, v) : this.store.getAt(0);
    ....
    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.

  4. #4
    Sencha User blessan's Avatar
    Join Date
    May 2010
    Posts
    316
    Vote Rating
    1
    blessan is on a distinguished road

      0  

    Default


    Having a way to set selection to none would be good.
    tfrugia I did not find a bug post. Have you made one?

  5. #5
    Touch Premium Member
    Join Date
    Dec 2007
    Posts
    109
    Vote Rating
    1
    tfrugia is on a distinguished road

      0  

    Default


    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.

  6. #6
    Ext User
    Join Date
    Aug 2010
    Posts
    7
    Vote Rating
    0
    Zielke is on a distinguished road

      0  

    Default


    I would prefer this 'feature' so you can use placeHolder as in any formfield.

  7. #7
    Sencha User blessan's Avatar
    Join Date
    May 2010
    Posts
    316
    Vote Rating
    1
    blessan is on a distinguished road

      0  

    Default


    Well anyway i made a post in the bugs. Hope something is done.

  8. #8
    Ext JS Premium Member
    Join Date
    Dec 2009
    Posts
    1
    Vote Rating
    0
    mscotece is on a distinguished road

      0  

    Default Need This

    Need This


    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.

  9. #9
    Sencha User
    Join Date
    Nov 2010
    Posts
    22
    Vote Rating
    0
    lexer is on a distinguished road

      0  

    Default


    Totally agree with you. Default selection is wrong behavior for optional fields.

  10. #10
    Sencha User
    Join Date
    Jul 2011
    Posts
    27
    Vote Rating
    0
    lpfx is on a distinguished road

      0  

    Default Workaround

    Workaround


    Set the property "value" of the selectfield to ' ' (empty), like this:

    Code:
    {
          xtype : 'selectfield',
          displayField : 'name',
          valueField : 'id',
          value : ' ',    // here
          placeHolder : 'Select...',
          store : myStore
    }
    The problem for me is to display the placeHolder... it is defined, but is not showing in my form.
    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?

Similar Threads

  1. get text in select. Not the selection
    By sofway in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 26 Mar 2010, 7:13 AM
  2. text selection in 'center' during menu select
    By andynuss in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 11 Jul 2009, 4:49 AM
  3. How i know when a Checkbox Selection model is a select or deselect?
    By vanderbill in forum Ext GWT: Help & Discussion (1.x)
    Replies: 3
    Last Post: 11 Feb 2009, 3:46 PM
  4. Selection on ComboBox doesnt select an item
    By digitalkaoz in forum Ext.air for Adobe AIR
    Replies: 4
    Last Post: 3 Nov 2008, 1:57 AM
  5. Multi-Select cell selection model, how to create?
    By DragonFist in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 1 May 2008, 7:28 AM

Thread Participants: 10