Skip to content

Instantly share code, notes, and snippets.

@derjabkin
Created September 13, 2013 11:24
Show Gist options
  • Save derjabkin/6549465 to your computer and use it in GitHub Desktop.
Save derjabkin/6549465 to your computer and use it in GitHub Desktop.
XAF ASP.NET Shortcut for an action
public class ActionContainerHolderEx : ActionContainerHolder
{
protected override DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.MenuActionItemBase CreateSimpleActionItem(DevExpress.ExpressApp.Actions.SimpleAction simpleAction)
{
SimpleActionMenuActionItem item = base.CreateSimpleActionItem(simpleAction) as SimpleActionMenuActionItem;
if (item != null)
{
ModificationsController controller = item.Action.Controller as ModificationsController;
if (controller != null)
{
IModelDetailViewSaveAndCloseOnEnter model =
controller.View.Model as IModelDetailViewSaveAndCloseOnEnter;
if (model != null && model.SaveAndCloseOnEnter)
{
if (item.Action.Id == "SaveAndClose")
{
Menu.ClientSideEvents.Init =
@"function(s,e) {
document.onkeyup = function(e) {
var keyCode = (window.event) ? event.keyCode : e.keyCode;
if (keyCode == 13) {" +
item.GetScript(((ICallbackManagerHolder) Page).CallbackManager, UniqueID, "1") +
//HACK: IndexPath = "1" for the Save&Close command.
";} } }";
}
}
}
}
return item;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment