Ticket Q402511
Visible to All Users

Use Js to fire Xaf Simple Action

created 13 years ago

Hi
I am looking for way to fire XAF Simple action with use of js. I have seen a cool feature on zimbra web client in relation to keyboard shortcuts. For example to create a new mail you press n followed by m. It's save allot of time. I just want to fire an action with javascript logic that all.
In addition to that I would like to override the click event simple action button. I would like to use double click instead of single click to launch action.

Thanks
Jaspreet

Comments (3)
Anatol (DevExpress) 13 years ago

    I am afraid that I cannot answer this question without knowing your real scenario, because there are several solutions, and each is appropriate only in specific cases. Please describe your scenario in greater detail.

      Hi Anatol
      Thanks for your reply. I have seen a cool feature on zimbra web client in relation to keyboard shortcuts. For example to create a new mail you press n followed by m. It's save allot of time. I just want to fire an action with javascript logic that all.
      It will be very nice of you if your can point all the possible methods if they exist in you previous database. If not the case just describe the most reliable solution to accomplish this.

      Anatol (DevExpress) 13 years ago

        I am afraid that we do not have many examples in our database, so I cannot direct you to them. I have posted a solution for your task in the answer to this ticket.

        Answers

        created 13 years ago (modified 13 years ago)

        Hello Jaspreet,
        I am afraid that shortcuts are not supported out-of-the-box by either ASPxMenu or XAF. However, it is possible to execute the click event of the ASPxMenu on the client side. This approach is used by EasyTest. Below is the sample code. It has several undocumented functions and properties, and I cannot guarantee that it will work properly in all situations. In this example, a button is placed on the main web template and the New action is executed on its client-side Click event. You can use the same approach for other client-side events.
        Default.aspx

        ASPx
        <dx:ASPxButton runat="server" ID="RiseItemClickButton" Text="Rise ItemClick" Width="100px" AutoPostBack="false" /> <bold>

        Default.aspx.cs</bold>

        C#
        RiseItemClickButton.ClientSideEvents.Click = string.Format(@"function(s, e){{ if (ASPxClientMenuLiteRenderHelper.GetItemOnClick){{ var menu = ASPxClientMenuBase.GetMenuCollection().GetMenu('{0}'); if (menu){{ var indexPath = menu.GetItemByName('{1}').GetIndexPath(); var funcItemClick = ASPxClientMenuLiteRenderHelper.GetItemOnClick(menu, menu.name, menu.GetItemElement(indexPath), indexPath); funcItemClick(document.createEventObject()); }} }} }}", TB.Menu.ClientID, "New");

        As an alternative approach, you can raise the XAF callback, as shown in the How to raise XAF CallBacks from client-side events example, and call the required server-side code. For example, execute the required action via its DoExecute method.
        >> In addition to that I would like to override the click event simple action button. I would like to use double click instead of single click to launch action.
        The ASPxMenu does not support this functionality - see ASPxMenu - Is there a way to make all buttons clickable versus mouse over.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.