[FIXED] [#932] [3.2.1] Combobox forceselection=true state clear issue

  1. #1

    [FIXED] [#932] [3.2.1] Combobox forceselection=true state clear issue

    Hi,

    I have a strange problem with combobox in ext.net v3.2.1.

    The issue is :

    1 - Set the forceselection = true and allowBlank = true
    2 - Select an item from combobox
    3 - Clear the combobox
    4 - After lost focus the combobox, previous value still selected.

    the same issue is exists in your examples page https://examples3.ext.net/#/Form/ComboBox/Overview/ "transformation combobox example"
    Last edited by fabricio.murta; Apr 23, 2016 at 4:41 PM.
  2. #2
    Hi @vzx,

    Well, it is the behavior of ForceSelection="true". When you edit and blur, it tries to find an item according to the entered text and if no item it reverts back the previous item.

    I could recommend a ClearButton plugin to provide users with a possibility to clear the ComboBox.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "1", "Item 1" },
                    new object[] { "2", "Item 2" },
                    new object[] { "3", "Item 3" }
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:ComboBox 
                ID="ComboBox1" 
                runat="server" 
                DisplayField="text" 
                ValueField="value"
                ForceSelection="true">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="value" />
                                    <ext:ModelField Name="text" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Reader>
                            <ext:ArrayReader />
                        </Reader>
                    </ext:Store>
                </Store>
                <Plugins>
                    <ext:ClearButton runat="server" HideOnMouseOut="false" />
                </Plugins>
            </ext:ComboBox>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil,

    Using Plugin is a solution but it is not possible to clear combobox with keyboard in that case. And I have to add this plugin to all combobox in my project.

    For workaround, I override the combobox with code below:

    Ext.define('My.overrides.form.field.ComboBox', {
        override: 'Ext.form.field.ComboBox',
        beforeBlur: function () {
            var value = this.getRawValue();
            if (value == '') {
                this.lastSelectedRecords = [];
            }
            this.doQueryTask.cancel();
            this.assertValue();
        }
    });
    But I am wondering if you will fix this issue. Because I think when I set AllowBlank="true" ForceSelection="true" I should clear the combobox easily like before (V3.1).

    Thanks,

    Vzx
  4. #4
    Confirm the behavior with Ext.NET 3.1.

    Interesting, tested with the latest Ext.NET v2 and the current 3.2.1 is presented there, i.e. the value recovers on blur.

    So,
    v2 latest: the value recovers on blur
    v3.1: the value doesn't recover on blur
    v3.2.1: the value recovers on blur

    As for the difference between v3.1 and v3.2.1 I am pretty sure it changed after this bug report:
    https://www.sencha.com/forum/showthread.php?298183

    So, somebody considered the behavior of not recovering the value as a bug. You consider the current behavior as a bug and personally I tend to agree with you. But it looks like there are two camps on that:)

    Personally, I am reluctant to change the current behavior since it will bother the "I need recovering" camp. Ideally, it would be great to have a setting to manage the behavior. I will log it in GitHub not to forget about this issue. Though, I don't think it is going to be changed or the setting appears any time soon.
    https://github.com/extnet/Ext.NET/issues/932

    As for your override, I think it is a nice solution.
  5. #5
    Hi Daniil,

    Recovering the previous value is OK.

    The problem is when i set allowBlank="true" ForceSelection="true" i can not clear combobox with simple delete action.

    The description at the bug report you provided says that it happens when allowBlank="false" so it is not the same case.

    Fixing this behaviour whenallowBlank="true" ForceSelection="true" should not be problem for anoyone.

    Thanks,

    Vzx
  6. #6
    Well, the issue is reproducible with either AllowBlank="true" or AllowBlank="false".

    Generally speaking, AllowBlank is initially designed for validation only. It means that it doesn't affect input. If the field is blank and AllowBlank="false", then validation fails and that is it. It doesn't actually prevent the field getting empty or something.

    The description at the bug report you provided says that it happens when allowBlank="false" so it is not the same case.
    Just to clarify - I didn't say it is the same case. I meant that fixing this case changed the behavior from what you need to what you don't need.

    I posted a follow-up in the Sencha forum thread:
    https://www.sencha.com/forum/showthr...=1#post1120543
  7. #7
    Hello! I couldn't reproduce this issue on upcoming Ext.NET 4.1, and the related sencha issue says they have fixed it. There's more details on the github issue that corroborate sencha's claim.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [OPEN] [#136] ComboBox ForceSelection problem
    By FpNetWorth in forum 2.x Legacy Premium Help
    Replies: 15
    Last Post: May 15, 2014, 5:13 AM
  2. Replies: 12
    Last Post: Nov 15, 2013, 3:34 AM
  3. Combobox with forceselection and loadRecord
    By nukarsoft in forum 2.x Help
    Replies: 0
    Last Post: Jan 07, 2013, 2:38 PM
  4. [CLOSED] ComboBox ForceSelection=False and Change Event
    By Steve in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 13, 2009, 2:48 AM
  5. [CLOSED] What does ForceSelection do in ComboBox?
    By harafeh in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 16, 2009, 1:48 PM

Tags for this Thread

Posting Permissions