[CLOSED] MultiCombo BeforeDeselect event

  1. #1

    [CLOSED] MultiCombo BeforeDeselect event

    Hello, I am wondering, why is the BeforeDeselect event fired just right after I click on the MultiCombo.

    My scenario:
    I need to preselect all items in the multicombo, so I call the combo.selectAll() method in its store's Load event. All items are selected correctly, but after dropping down the combo, the BeforeDeselect event is called with index 0, it shouldn't be. If I preselect the items using the same method combo.selectAll called from the combo's BeforeSelect event (or from firebug console), the combo is working like expected, and the BeforeDeselect method is not called upon drop down...

    Whats wrong?

    Thanks!

    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <!DOCTYPE html>
     
    <html>
        <head runat="server">
            <title>Ext.NET Example</title>
    
            <ext:XScript runat="server">
                <script type="text/javascript">
                    var comboSelect = function (combo, records, index, eOpts) {
                        console.debug('select');
                        if (index == 0) {
                            combo.selectAll();
                        }
    
                    };
    
                    var comboDeselect = function (combo, records, index, eOpts) {
                        console.debug('deselect');
                        console.debug(combo, records, index, eOpts);
                        if (index == 0) {
                            combo.suspendEvent('beforedeselect');
                            combo.clearValue();
                            combo.resumeEvent('beforedeselect');
                        }
                    };
    
                </script>
            </ext:XScript>
    
            <script runat="server">
    
                private object TestData
                {
                    get
                    {
                        return new object[]
                        {
                            new object[] {"AL", "Alabama", "The Heart of Dixie"},
                            new object[] {"AK", "Alaska", "The Land of the Midnight Sun"},
                            new object[] {"AZ", "Arizona", "The Grand Canyon State"},
                            new object[] {"AR", "Arkansas", "The Natural State"},
                            new object[] {"CA", "California", "The Golden State"},
                            new object[] {"CO", "Colorado", "The Mountain State"},
                            new object[] {"CT", "Connecticut", "The Constitution State"},
                            new object[] {"DE", "Delaware", "The First State"},
                            new object[] {"DC", "District of Columbia", "The Nation's Capital"},
                            new object[] {"FL", "Florida", "The Sunshine State"},
                            new object[] {"GA", "Georgia", "The Peach State"},
                            new object[] {"HI", "Hawaii", "The Aloha State"},
                            new object[] {"ID", "Idaho", "Famous Potatoes"},
                            new object[] {"IL", "Illinois", "The Prairie State"},
                            new object[] {"IN", "Indiana", "The Hospitality State"},
                            new object[] {"IA", "Iowa", "The Corn State"},
                            new object[] {"KS", "Kansas", "The Sunflower State"},
                            new object[] {"KY", "Kentucky", "The Bluegrass State"},
                            new object[] {"LA", "Louisiana", "The Bayou State"},
                            new object[] {"ME", "Maine", "The Pine Tree State"},
                            new object[] {"MD", "Maryland", "Chesapeake State"},
                            new object[] {"MA", "Massachusetts", "The Spirit of America"},
                            new object[] {"MI", "Michigan", "Great Lakes State"},
                            new object[] {"MN", "Minnesota", "North Star State"},
                            new object[] {"MS", "Mississippi", "Magnolia State"},
                            new object[] {"MO", "Missouri", "Show Me State"},
                            new object[] {"MT", "Montana", "Big Sky Country"},
                            new object[] {"NE", "Nebraska", "Beef State"},
                            new object[] {"NV", "Nevada", "Silver State"},
                            new object[] {"NH", "New Hampshire", "Granite State"},
                            new object[] {"NJ", "New Jersey", "Garden State"},
                            new object[] {"NM", "New Mexico", "Land of Enchantment"},
                            new object[] {"NY", "New York", "Empire State"},
                            new object[] {"NC", "North Carolina", "First in Freedom"},
                            new object[] {"ND", "North Dakota", "Peace Garden State"},
                            new object[] {"OH", "Ohio", "The Heart of it All"},
                            new object[] {"OK", "Oklahoma", "Oklahoma is OK"},
                            new object[] {"OR", "Oregon", "Pacific Wonderland"},
                            new object[] {"PA", "Pennsylvania", "Keystone State"},
                            new object[] {"RI", "Rhode Island", "Ocean State"},
                            new object[] {"SC", "South Carolina", "Nothing Could be Finer"},
                            new object[] {"SD", "South Dakota", "Great Faces, Great Places"},
                            new object[] {"TN", "Tennessee", "Volunteer State"},
                            new object[] {"TX", "Texas", "Lone Star State"},
                            new object[] {"UT", "Utah", "Salt Lake State"},
                            new object[] {"VT", "Vermont", "Green Mountain State"},
                            new object[] {"VA", "Virginia", "Mother of States"},
                            new object[] {"WA", "Washington", "Green Tree State"},
                            new object[] {"WV", "West Virginia", "Mountain State"},
                            new object[] {"WI", "Wisconsin", "America's Dairyland"},
                            new object[] {"WY", "Wyoming", "Like No Place on Earth"}
                        };
                    }
                }
    
            </script>
        </head>
    
        <body>
            <form runat="server">
                <ext:ResourceManager runat="server" />
    
                <ext:MultiCombo 
                    ID="MyCombo"
                    runat="server"
                    FieldLabel="Select multiple states"                    
                    DisplayField="name"
                    Width="320"
                    LabelWidth="130"
                    >
                    <Store>
                        <ext:Store runat="server" Data="<%# TestData %>" AutoDataBind="true">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="abbr" />
                                        <ext:ModelField Name="name" />
                                        <ext:ModelField Name="slogan" />
                                    </Fields>
                                </ext:Model>
                            </Model>
    
                            <Reader>
                                <ext:ArrayReader />    
                            </Reader>
                                
                            <Listeners>
                                <Load Handler="#{MyCombo}.selectAll();" Delay="10"></Load>
                            </Listeners>
                        </ext:Store>
                    </Store>
                    
                    <Listeners>
                        <BeforeSelect Fn="comboSelect"></BeforeSelect>
                        <BeforeDeselect Fn="comboDeselect"></BeforeDeselect>
                    </Listeners>
                </ext:MultiCombo>
    
            </form>
        </body>
    </html>
    Last edited by Daniil; Oct 13, 2014 at 2:44 PM. Reason: [CLOSED]
  2. #2
    Hi @exe,

    Welcome to the Ext.NET forums!

    Please set this setting for the MultiCombo.
    QueryMode="Local"
    Otherwise, it is Remote by default and the MultiCombo re-request the data on trigger click and, therefore, the Store's Load event is fired again.

    Also, I think you could set Single="true" for the Load listener.
  3. #3
    Daniil,
    now it's working as expected. Single="True" also makes sense.

    SOLVED!

    Thank you!

Similar Threads

  1. Replies: 0
    Last Post: Jun 01, 2013, 10:41 AM
  2. MultiCombo and IE8
    By Birgit in forum 2.x Help
    Replies: 1
    Last Post: Dec 07, 2012, 9:15 AM
  3. selected value in MultiCombo
    By difa in forum 1.x Help
    Replies: 1
    Last Post: Dec 08, 2011, 1:30 PM
  4. [CLOSED] MultiCombo Change Event Not Saving ViewState
    By garrisrd in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Nov 29, 2011, 8:26 PM
  5. [CLOSED] MultiCombo Tooltip BeforeShow Event
    By softmachine2011 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 22, 2011, 12:07 PM

Tags for this Thread

Posting Permissions