[CLOSED] Combo BeforeSelect Event

  1. #1

    [CLOSED] Combo BeforeSelect Event

    Hi,

    When I have a beforeselect listener in a combo with a function inside it seems to loop the event fire. Or at least in v1.x with the same code doesn't have the same behaviour.

    TEST CASE

    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
        <script type="text/javascript">
            var myFunction = function (combo, record, index) {
                var newValue = record.data.field1;
    
                combo.collapse();
    
                var messageWindow = Ext.Msg.show({ title: 'App Title',
                    msg: 'My question message....?',
                    buttons: Ext.Msg.YESNO,
                    fn: function (buttonId) {
                        if (buttonId == 'yes') {
                            combo.setValue(newValue);
                        }
                    },
                    icon: Ext.Msg.QUESTION
                });
    
                return false;
            }
        </script>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:ComboBox runat="server">
            <Items>
                <ext:ListItem Text="Item 1" Value="1" Mode="Raw" />
                <ext:ListItem Text="Item 2" Value="2" Mode="Raw" />
                <ext:ListItem Text="Item 3" Value="3" Mode="Raw" />
            </Items>
            <Listeners>
                <BeforeSelect Fn="myFunction" />
            </Listeners>
        </ext:ComboBox>
        </form>
    </body>
    </html>
    In my project I reproduce it with an store not with items inside the combo. If it might helps you.
    Last edited by Daniil; Sep 07, 2012 at 8:51 AM. Reason: [CLOSED]
  2. #2
    Hi,

    The setValue method causes a Select event to be fired.

    I can suggest to lock BeforeSelect listener before the setValue call and unlock after.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Examples</title>
    
        <script type="text/javascript">
            var onBeforeSelect = function (combo, record) {
                if (!combo.lockedBeforeSelect) {
                    Ext.Msg.show({ 
                        title   : 'Confirmation',
                        msg     : 'Are you sure?',
                        buttons : Ext.Msg.YESNO,
                        icon    : Ext.Msg.QUESTION,
                        fn      : function (buttonId) {
                            if (buttonId === 'yes') {
                                combo.lockedBeforeSelect = true;
                                combo.setValue(record.get(combo.valueField));
                                combo.lockedBeforeSelect = false;
                            }
                        }
                    });
     
                    return false;
                }
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:ComboBox runat="server">
            <Items>
                <ext:ListItem Text="Item 1" Value="1" Mode="Raw" />
                <ext:ListItem Text="Item 2" Value="2" Mode="Raw" />
                <ext:ListItem Text="Item 3" Value="3" Mode="Raw" />
            </Items>
            <Listeners>
                <BeforeSelect Fn="onBeforeSelect" />
            </Listeners>
        </ext:ComboBox>
    </body>
    </html>
  3. #3
    Ok I had applied this fix.

    Thanks

Similar Threads

  1. Combo box event handler
    By Shuaib in forum 1.x Help
    Replies: 1
    Last Post: Oct 10, 2012, 1:59 PM
  2. [CLOSED] Question about event calls by combo box value.
    By rosua in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 19, 2012, 11:53 AM
  3. Replies: 3
    Last Post: May 11, 2010, 10:36 AM
  4. [CLOSED] [1.0] Combo box add event runtime
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jan 21, 2010, 11:03 AM
  5. combo box change ajax event
    By [WP]joju in forum 1.x Help
    Replies: 2
    Last Post: Sep 30, 2009, 9:46 AM

Tags for this Thread

Posting Permissions