重新排列标题按钮 [英] Reordering header buttons

查看:88
本文介绍了重新排列标题按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在销售订单屏幕中添加了一个自定义保存按钮来代替当前的按钮。如何重新排序主工具栏,以便新的保存按钮代替旧的?您可以轻松地对网格按钮执行此操作,但是对于标题按钮则不太容易。

I have added a custom save button in Sales Order screen in place of my current one. How do I reorder the main toolbar so that new save button is in place of the old one? You can do this easily for grid buttons, but for header ones it is not so obvious.

推荐答案

按钮的顺序为根据图中PXAction的顺序。

The order of the buttons is based on the order of the PXActions in the graph.

(1)在此示例中,我的保存按钮是第一个,然后是取消按钮。

(1) In this example my save button is first, then cancel button second.

public class MyGraph : PXGraph<MyGraph>
{
    public PXSave<MyPrimaryDac> Save;
    public PXCancel<MyPrimaryDac> Cancel;
}

(2)在此示例中,我的取消按钮是第一个,然后是保存按钮。

(2) In this example my cancel button is first, then save button second.

public class MyGraph : PXGraph<MyGraph>
{
    public PXCancel<MyPrimaryDac> Cancel;
    public PXSave<MyPrimaryDac> Save;
}

请注意,PXSave和PXCancel是PXAction。

编辑:通过注释和问题编辑,如果要扩展另一个图形,则应该能够使用从PXSave继承的新类并设置属性命名相同(在销售订单示例中为保存)。这是应该替代保存按钮并询问用户问题并将保存按钮保持在相同按钮位置的东西。

Edit: from comments and question edits if you are extending another graph you should be able to use a new class inherited from PXSave and set the property name the same ("Save" in the example of sales order). Here is something that should work for an override to the save button and asking the user a question and keeps the save button in the same button location...

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    public SalesPXSave<SOOrder> Save;

    public class SalesPXSave<TNode> : PXSave<TNode> where TNode : class, IBqlTable, new()
    {
        public SalesPXSave(PXGraph graph, string name) : base(graph, name)
        {
        }

        public SalesPXSave(PXGraph graph, Delegate handler) : base(graph, handler)
        {
        }

        [PXSaveButton]
        [PXUIField(DisplayName = "Save", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
        protected override IEnumerable Handler(PXAdapter adapter)
        {
            bool someCondition = true;
            if (someCondition)
            {
                if (adapter.View.Ask(adapter.View.Graph.Caches[typeof(TNode)].Current, "Hi User",
                    MessageButtons.YesNo) != WebDialogResult.Yes)
                {
                    return adapter.Get();
                }
            }

            return base.Handler(adapter);
        }
    }
}

编辑:作为参考,这里有一些快速的未经测试的示例,它们是扩展RowPersisting或扩展中的Persist(如果首选)而不是扩展按钮...

For reference here are some quick untested examples of extending RowPersisting or the Persist in an extension if this is preferred vs extending the buttons...

[PXOverride]
public virtual void Persist(Action del)
{
    if (Base.Document.Ask(Base.Document.Current, "Question", "Continue?",
            MessageButtons.YesNo) != WebDialogResult.Yes)
    {
        return;
    }

    del?.Invoke();
}


protected virtual void SOOrder_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting del)
{
    var row = (SOOrder)e.Row;
    if (row == null)
    {
        return;
    }

    if ((e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update || e.Operation == PXDBOperation.Delete) &&
        Base.Document.Ask(row, "Question", "Continue ?", MessageButtons.YesNo, true) != WebDialogResult.Yes)
    {
        e.Cancel = true;
        return;
    }

    del?.Invoke(cache, e);
}

这篇关于重新排列标题按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆