Hide Columns in a Grid - acumatica

Is it possible to dynamically hide columns in a grid (using AEF). For example, based on certain conditions I want to hide certain columns in my graph dynamically.
I have used the RowSelectedEvent and have tried to use PXUIField Visibility functionality but it is not hiding the column.
Is there a way to hide the columns from the Graph?

RowSelected should work. Check correctness of what you typed:
1. RowSelected should be protected.
2. Check that you pass into RowSelected PXCache and PXRowSelectedEventArgs
3. Check that in your SetVisible method you pass proper column
4. Check that you pass in method SetVisible proper view
5. Check that you didn't forget to passed not just view but Cache property of view
6. Check that you chosen correct DAC class. Sometime two different DAC classes can represent the same table ( for exapmple APRegister, APInvoice. Or POOrder, POOrder2 )
Here is sample from my working project:
protected void POOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
PXUIFieldAttribute.SetVisible<POOrderExt.allAmt>(this.VendorOrders.Cache, null, false);
//this code hides column in my grid
}

Related

Implement event handler in a grid and concatenate values

I'm looking for the way how to implement RowUpdated event handler in Answers grid. I've implemented RowUpdated event handler in the value column of the grid but it doesn't work.
I want to concatenate the value of the attribute column value in the description field when I change the value from the drop-down list
Can anyone provide advice please?
protected virtual void CSAnswers_Value_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
}
Works fine on my instance, BUT event will be raised only if
Focus has been changed
Ctrl+Enter pressed
Which is fine from my standpoint. Do you really need to get an event right after the value changing?

How do I hide an entire row in a gird?

Is there a way to hide an entire row, not just a single column, in a grid? I'm tried PXUIField.SetVisible, PXUIField.SetVisibility, PXUISetVisible, and PXUISetVisibility, but none of them seem to work. I know that using PXUIField.SetEnabled(cache, row, false) disabled the entire row, but can I make an entire row invisible?
You need to make sure the row is not returned in the query (could override the view delegate and not return specific rows) or removed from the cache. I don't think there is anything that can hide a row using the UI related calls, but I have never come across the need for this to ever try it.
The usual pattern is to use a PXFilter DataView current DAC record to filter the PXSelect DataView bound to the grid.
The filter fields are often changed on screen directly by the user but you can also set the value of the current filter DAC record programmatically in event handlers to build more complex logic.
public PXFilter<DACFilter> Filter;
public PXSelect<DAC,
Where<DACFilter.field, Equal<Current<DACFilter.fieldFilter>>>> GridDataView;

How to add the OrderNbr hyperlink in SOLine

I have a grid which displays only SOLine and SOOrder data. In my case, SOLine is the main DAC, because the purpose of the grid is to perform mass updates of the transactions. I wish to add the OrderNbr in the grid, so the user can select and open the sales order popup. I notice the order number field does not appear as a hyperlink, if use SOOrder table in my grid. Next I try SOLine.orderNbr. However the field type is only TextEdit. Here is a workaround
I created the SOLine cache extended and defined a non-bound field. Something simple like ExtraSOOrder field. Next I create a PXAction which creates the SOOrderEntry graph and performs the redirect, and achieves the goal. I notice something odd in the grid. OrderNbr is displayed twice. Although the field is only added once in the grid, the webpage adds the field a second time. In fact, the user is unable to remove the duplicate order number field, in the column selector. The duplicate field has a yellow icon which I have not seen before.
What is the best way to add the redirect, to the sales order entry page? The behavior works perfectly for the Inventory item field in this grid. OrderNbr is more challenging.
All that was required was to add the SOOrder.orderNbr to the grid columns collection. Then assign the action to the Linkedcommand property, to that field. No need to create a cache extension for all of this.

How to conditionally hide PXTabItem inside an Acumatica screen?

I want to HIDE the Sales Order Line Commissions Tab, but I only want the Tab Hidden for a Specific Role. Is this possible?
Option #1: Using PXTabItem VisibleExp property
This approach works perfectly with fairly simple declarative conditions, which utilize input control values from a particular container (PXForm is most commonly used for this scenario).
For example, to hide the Sales Order Commissions tab for orders of the TR type, you should compose VisibleExp as follows:
<px:PXTabItem Text="Commissions"
VisibleExp="DataControls["edOrderType"].Value!=TR"
BindingContext="form"
RepaintOnDemand="false">
A quick overview of the 3 PXTabItem properties used in the code snippet above:
BindingContext: the ID of the container control hosting input controls used to calculate visible property for PXTabItem
VisibleExp: the expression to calculate visible property for PXTabItem
RepaintOnDemand: controls the initialization of PXTab control. When set to True (the default value) PXTabItem will be initialized only when a user selects the Tab, otherwise, it will initialize with every postback.
Option #2: In code hide all controls placed inside PXTabItem
Without a doubt, this approach is a step forward in terms of flexibility comparing to PXTabItem VisibleExp property. It allows you to compose way more complex conditions inside business logic and do not rely on a webpage.
To hide the Sales Order Commissions tab, you should subscribe to the RowSelected handler for SOOrder as follows:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
SOOrder order = (SOOrder)e.Row;
if (order == null) return;
bool financeRoleMember = System.Web.Security.Roles.IsUserInRole("FINANCE");
Base.SalesPerTran.AllowSelect = financeRoleMember;
PXUIFieldAttribute.SetVisible<SOOrder.salesPersonID>(Base.Document.Cache, null, financeRoleMember);
}
}
With AllowSelect property set to false, the SalesPerTran data view will automatically hide every PXGrid, whose DataMember property is set to SalesPerTran. Since the Sales Order Commissions tab also contains Default Salesperson lookup, we need to additionally set Visible property to false for the PXUIFieldAttribute decorating SOOrder SalesPersonID field. PXTabItem automatically hides when it contains no visible controls.
Please be advised, similar to PXTabItem VisibleExp property, in order for this approach to function properly, you have to always set RepaintOnDemand to false for the PXTabItem you conditionally hide. For this particular example, we can skip this step, because RepaintOnDemand is set to false in the original SO301000.aspx file distributed by Acumatica.

Changing Labels for a Single DAC Field Used Multiple Times

My scenario involves fetching data from a table that returns multiple results to be displayed. My problem is that when I add the fields on the screen, the labels are all the same. I am pulling notes from 3 different screens onto one screen to display for the user. The notes are from a Sales Order, Customer, and Inventory Item. The data is being pulled correctly for each screen, but the label for each text box is "NoteText." I would like to change these labels to more accurately reflect which screen the note is from.
Thanks.
If I'm understanding your question correctly, you'll want to use a Cache Attached event handler for the fields in question. CacheAttached event handlers allow you to change the attributes of a field within the graph.
[PXUIField(DisplayName = "SO Notes")]
protected void SOOrder_NoteText_CacheAttached(PXCache sender)
{}
This may be specific to my situation, but I found a solution. What I am doing is suppressing the generated titles and customizing RowSelecting() of the DAC to add my own titles within the NoteText based on the note's GraphType parameter. I have all other parameters to filter down to the three notes I would need to display for that specific page. I use the GraphType to insert the text in front of the note to generate my own label for it.

Resources