-->

Add extra note field to grid line

2019-09-16 14:58发布

问题:

I have a client that would like to add an extra note field to a grid. If this is not possible, is there a way to have a large text field in a grid that uses a pop up window for editing the large amount of text in that field?

Priority: 1.) Add extra note field to grid, if possible. 2.) Failing #1, is there a way to add a popup window to edit a large standard user text field.

回答1:

I believe the answer to your number 1 question is no. If the grid already has a note it cannot have another. I had this question come up before.

For #2, you should be able to do a smart panel that displays your field. Use a PXTextEdit and setup a new view for the panel to point to based on your selected/current row.

To add a smart panel (pop up panel) you need a handful of things in place. I prefer using AEF with graph and table extensions. There is documentation in the T200/T300 training material for these topics. In my example I add the note ability to the sales order page. I copied most of the logic from the existing "PO Link" button and panel which is the POSupplyOK PXAction and the currentposupply view (page SO301000).

First you need your new field which we will add to the sales line as an extension table/field:

 [PXTable(typeof(SOLine.orderType), typeof(SOLine.orderNbr), typeof(SOLine.lineNbr), IsOptional = true)]
public class SOLineExtension : PXCacheExtension<SOLine>
{
    #region XXMyNote
    public abstract class xXMyNote : PX.Data.IBqlField
    {
    }
    protected string _XXMyNote;
    [PXDBString]
    [PXUIField(DisplayName = "My Note")]
    public virtual string XXMyNote
    {
        get
        {
            return this._XXMyNote;
        }
        set
        {
            this._XXMyNote = value;
        }
    }
    #endregion
}

Then we need to create a new graph extension to add the view for the panel and the PXAction for the button to open the panel.

public class SOOrderEntryExtension : PXGraphExtension<SOOrderEntry>
{

    public PXSelect<SOLine,
        Where<SOLine.orderType, Equal<Current<SOLine.orderType>>,
            And<SOLine.orderNbr, Equal<Current<SOLine.orderNbr>>,
                And<SOLine.lineNbr, Equal<Current<SOLine.lineNbr>>>>>> MyPanelView;

    public PXAction<SOOrder> myNoteAction;
    [PXUIField(DisplayName = "Add Note", MapViewRights = PXCacheRights.Select, MapEnableRights = PXCacheRights.Update)]
    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
    protected virtual IEnumerable MyNoteAction(PXAdapter adapter)
    {
        if (Base.Transactions.Current != null &&
            MyPanelView.AskExt() == WebDialogResult.OK)
        {
            //extra stuff here if needed when OK is pushed
        }

        return adapter.Get();
    }
}

now you need to "edit" the sales order page. you need to get your changes into a customization project and I usually go edit the page direct in visual studio under site\pages\so in this example. Then come back and paste in my code into the customization project by opening the project and performing the following steps:

  1. Click on screens and the + sign to add a new screen
  2. Enter SO301000 and save
  3. Click on the SO301000 hyperlink to open the layout editor for sales order
  4. Click Actions > Edit ASPX
  5. Paste in your changes (mentioned below)

In the SO301000 page add the following:

[1] Add your DS Callback command within the PXDataSource tag

<px:PXDSCallbackCommand Name="MyNoteAction" Visible="False" 
    CommitChanges="true" DependOnGrid="grid" />

[2] Add the button to the toolbar above the sales line grid by adding the following to the PXGrid > ActionBar > CustomItems tags of the grid in the Document Details tab. (just search "PO Link" in the page to find this location easier or any of the listed buttons above the grid).

<px:PXToolBarButton Text="Add Note" DependOnGrid="grid">
    <AutoCallBack Command="MyNoteAction" Target="ds" />
</px:PXToolBarButton>

[3] Add the panel code which represents what the panel will look like. You can play around with the sizing to fit your needs, just make sure you set your PXTextEdit to use MultiLine using the following example code. Look at the current sales order page to know where it fits into the page syntax:

<px:PXSmartPanel ID="PXSmartPanelNote" runat="server" Caption="My Note Panel Caption"
    CaptionVisible="true" DesignView="Hidden" LoadOnDemand="true" Key="MyPanelView" CreateOnDemand="false" AutoCallBack-Enabled="true"
    AutoCallBack-Target="formMyNote" AutoCallBack-Command="Refresh" CallBackMode-CommitChanges="True" CallBackMode-PostData="Page"
    AcceptButtonID="btnMyNoteOk">
    <px:PXFormView ID="formMyNote" runat="server" DataSourceID="ds" Style="z-index: 100" Width="100%" CaptionVisible="False"
        DataMember="MyPanelView">
        <ContentStyle BackColor="Transparent" BorderStyle="None" />
        <Template>
            <px:PXLayoutRule ID="PXLayoutRule44" runat="server" StartColumn="True" LabelsWidth="S" ControlSize="XM" />
            <px:PXTextEdit ID="cstXXMyNote" runat="server" DataField="XXMyNote" TextMode="MultiLine"/>
        </Template>
    </px:PXFormView>
    <px:PXPanel ID="PXPanel10" runat="server" SkinID="Buttons">
        <px:PXButton ID="btnMyNoteOk" runat="server" DialogResult="OK" Text="OK"/>
    </px:PXPanel>
</px:PXSmartPanel>

I have not fully tested the above but a quick slap together brought up the panel with no errors. I was using version 6.00.0955 but the same steps should work in all 5.X versions. Hope this helps.



标签: acumatica