[CLOSED] CheckMenuItem Click and Check events

  1. #1

    [CLOSED] CheckMenuItem Click and Check events

    Hi,

    is it possible use CheckMenuItem and prevent the click event to be fired on check/uncheck ?
    here is my case:
    <ext:CheckMenuItem ID="GenerateSingle" runat="server" Text="Generate Single" Icon="PageWhite" CheckHandler="onItemCheck">
                            <DirectEvents>
                                     <Click  OnEvent="PublishLetterAsPdf"  />
                             </DirectEvents>
               </ext:CheckMenuItem>
    i want when check/uncheck the checkbox to just call onItemCheck not PublishLetterAsPdf.

    Thank you.
    Last edited by Daniil; Jul 23, 2014 at 12:59 PM. Reason: [CLOSED]
  2. #2
    Hi @snow_cap,

    I am not sure, but it is probably possible.

    Could you, please, clarify why you need both the events? It looks like they both fire on each click, don't they?
  3. #3
    No, they aren't the same, i want when the user check the checkbox to set a HiddenField to true, then on click i want get the HiddenField value.
    now if i click the menu it will always check the checkbox, so i code behind will be always true.
    thank you again
  4. #4
    Well, I have not meant the events are the same, I've meat that clicking causes check/uncheck.

    Ok, you want to distinguish these events.

    I can suggest to override the default CheckMenuItem's onClick handler.
    http://docs.sencha.com/extjs/4.2.1/s...method-onClick

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void CheckMenuItem_Click(object sender, DirectEventArgs e)
        {
            X.Js.Call("console.log", "CheckMenuItem_Click");
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var myOnClick = function(e) { 
                var me = this;
    
                if (e.getTarget("img.x-menu-item-icon-right")) {
                    if(!me.disabled && !me.checkChangeDisabled && !(me.checked && me.group)) {
                        me.setChecked(!me.checked);
                    }
                } else {
                    Ext.menu.CheckItem.superclass.onClick.call(me, e); 
                }
            };
    
            var onItemCheck = function () {
                console.log("CheckHandler");
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Menu runat="server" Width="200" Floating="false">
                <Items>
                    <ext:CheckMenuItem 
                        runat="server" 
                        Text="Item 1" 
                        Icon="Accept" 
                        CheckHandler="onItemCheck">
                        <CustomConfig>
                            <ext:ConfigItem Name="onClick" Value="myOnClick" Mode="Raw" />
                        </CustomConfig>
                        <DirectEvents>
                            <Click OnEvent="CheckMenuItem_Click" />
                        </DirectEvents>
                    </ext:CheckMenuItem>
    
                    <ext:CheckMenuItem 
                        runat="server" 
                        Text="Item 2" 
                        Icon="Add" 
                        CheckHandler="onItemCheck">
                        <CustomConfig>
                            <ext:ConfigItem Name="onClick" Value="myOnClick" Mode="Raw" />
                        </CustomConfig>
                        <DirectEvents>
                            <Click OnEvent="CheckMenuItem_Click" />
                        </DirectEvents>
                    </ext:CheckMenuItem>
                </Items>
            </ext:Menu>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Select all check box of gridpanel when button click
    By trePjt in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 29, 2013, 3:22 AM
  2. Replies: 3
    Last Post: Jan 08, 2013, 7:05 AM
  3. Replies: 1
    Last Post: Aug 02, 2011, 12:59 PM
  4. CheckMenuItem bug?
    By lbs7 in forum 1.x Help
    Replies: 3
    Last Post: Jun 30, 2010, 12:28 PM
  5. [CLOSED] GridPanel Cell click and check box selection
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jul 24, 2009, 7:55 AM

Posting Permissions