如何创建超链接用户字段 [英] How to create a hyperlink user field

查看:125
本文介绍了如何创建超链接用户字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户字段,其中显示ARRegister.RefNbr。该用户字段包含在APTran网格中。用户实际上使用自定义操作创建了AR发票,并且新的AR文档ref nbr被保存到APTran网格中。我希望将用户字段设置为超链接(类似于SO装运订单标签中的库存收货参考编号)。我应该使用PXSelector控件吗?适当的属性是什么?目的是在用户单击用户字段时打开AR发票屏幕。

I have a user field which displays the ARRegister.RefNbr. This user field is contained in the APTran grid. The user actually creates an AR invoice with a custom action, and the new AR document ref nbr is saved to the APTran grid. I wish to craft the user field as a hyperlink (similar to the inventory receipt reference number, in the SO shipment order tab). Should I use a PXSelector control? What are the proper attributes? The goal is to open the AR invoice screen, when the user click on the user field.

推荐答案

有一种通用方法可以允许您添加到网格单元的链接,并且不基于选择器或其他任何东西。要实现它,您必须执行以下步骤:

There is a generic approach that allows you to add links to the grid cells and isn't based on selectors or anything else. To implement it you have to do the following steps:

1。在图形中定义一个处理重定向的操作。这样的事情:

1.Define an action in your graph that handles redirects. Something like this:

public PXAction<YourMainDAC> ViewInvoice;

[PXButton]
protected virtual void viewInvoice()
{
    ARTran row = Transactions.Current;
    string docType = //get Doc Type from the tran record
    string refNbr = //get Ref Nbr from the tran record
    ARInvoice invoice = PXSelect<ARInvoice, 
        Where<ARInvoice.docType, Equal<Required<ARInvoice.docType>>,
          And<ARInvoice.refNbr, Equal<Required<ARInvoice.refNbr>>>>>
            .Select(this, row.YourDocTypeField, row.YourRefNbrField);

    // Create the instance of the destination graph
    ARInvoiceEntry graph = PXGraph.CreateInstance<ARInvoiceEntry>();
    graph.Document.Current = invoice;

    // If the invoice is found, throw an exception to open
    // a new window (tab) in the browser
    if (graph.Document.Current != null)
    {
        throw new PXRedirectRequiredException(graph, true, "AR Invoice");
    }
}

2。在.aspx页面定义中添加回调对应于新操作的命令(用页面上的 ARTran s网格的ID替换 grid ):

2.In the .aspx page definition add a callback command that corresponds to the new action (substitute grid with the ID of the ARTrans grid on your page):

<px:PXDataSource ID="ds" ... >
    <CallbackCommands>
        <px:PXDSCallbackCommand Name="ViewInvoice"
            Visible="False"
            DependOnGrid="grid">
        </px:PXDSCallbackCommand>
    </CallbackCommands>
</px:PXDataSource>

3。在要添加链接的网格列中,指定链接命令以指向上方 PXDSCallbackCommand

3.In the grid column where you want to add a link specify link command to point to the above PXDSCallbackCommand:

<px:PXGridColumn DataField="InvoiceNbrOrSomething"
                 LinkCommand="ViewInvoice">
</px:PXGridColumn>

这是定义链接的冗长方法,但首先,它不对链接施加任何约束在该字段中添加链接,它还使您可以完全控制要打开的图形以及在其中显示的内容。

This is a bit lengthy way of defining a link but, first, it does not impose any constraints on the field where you add a link and it also gives you full control over which graph to open and what to show there.

注意:您可能还需要设置 SyncPosition = true 在aspx的网格控件上。

Note: you may also need to set SyncPosition="true" on the grid control in the aspx.

该示例改编自Acumatica中的Example 3.4 T200培训指南。您可能需要检查一下,以获得一些详尽的解释和更多信息。

The example is adapted from the Example 3.4 in the Acumatica T200 training guide. You may want to check it out for some thorough explanations and more info.

这篇关于如何创建超链接用户字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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