Hi All,
Today want to share with you one new way how you can define navigation in Acumatica version 5.3.
From T200 Acumatica Framework Fundamentalist you may know that if you want to map action to any cell in the grid and show it as link you need to define LineCommand:
<px:PXGridColumn DataField="ProductID" Width="140px" LinkCommand="ViewProduct" />
But to be able to use it, you should define action, action handler, throw appropriate exception, hide it in data source and so on. Quite log and boring.
In Acumatica 5.3 there is a PXViewDetailsButtonAttribute that can do all these things for you.
[PXViewDetailsButton(typeof(Contact),typeof(Select<Contact, Where<Contact.contactID, Equal<Current<CROpportunity.contactID>>>>))] [PXViewDetailsButton(typeof(BAccount),typeof(Select<BAccount, Where<BAccount.ccbAccountID, Equal<Current<CROpportunity.customerID>>>>))] public PXSelectReadonly<CROpportunit> Opportunities;
This attribute will do following:
- Will add dynamic action with name <DataView_Name>_<DAC_Name>_ViewDetails. So in our example it will be Opportunities_BAccount_ViewDetails and Opportunities_Contact_ViewDetails.
- Will add an action handler where it will search for required entity based on provided BQL and do redirect.
- Will hide dynamic action in data sources.
So as the result you just can go to aspx file and use it!
<px:PXGridLevel DataMember="Opportunities"> <Columns> <px:PXGridColumn DataField="OpportunityID" /> <px:PXGridColumn DataField="BAccount__AcctCD" LinkCommand="Opportunities_BAccount_ViewDetails" /> <px:PXGridColumn DataField="Contact__DisplayName" LinkCommand="Opportunities_Contact_ViewDetails" /> </Columns> </px:PXGridLevel>
In the result you code is cleaner and the result is nicer.
Also note that you may have multiple PXViewDetailsButton attributes that will generate multiple buttons.
As an addition you can configure action behavior with attribute properties:
- Custom action name by explicitly specifying it
- Window open mode: popup or window
- What to do when popup is closed – refresh data for example.
Have a nice Development!