How to conditionally hide PXTabItem inside an Acumatica screen? - acumatica

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.

Related

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.

Force user to select only one value from filter spotfire

Is it possible to force the user to select only one value from a filter ?
For a radio button filter as below, is it possible to remove the buttons all & none and make sure that only one Choice is selected ?
you cannot change the existing filter features or functionality without developing a custom extension for a new filter control.
that said, you can certainly emulate a filter using what's called a Property Control and a Data Limiting Expression. for single selection, you're stuck with either a Dropdown control or a Listbox (single select) control.
you would need to...
create a Text Area Visualization on the page somewhere
insert a Listbox or Dropdown Property Control into the Text Area Visualization
create a Document Property with the same data type as your filter column and associate it to the Property Control. you can set this to Unique Values in Column or write in your own Fixed values.
open the Properties dialog on the visualization you'd like to filter and navigate to the Data page
scroll down to Limit Data Using Expression and use an expression like [MyFilterColumn] = "${MyDocumentProperty}" (quotes are required for string values; if numeric then omit quotes)
Please add this CSS in the HTML page of the spotifre to remove all and none
.ColumnFilter .sf-element-filter-item:last-of-type { display:none; }
.ColumnFilter .sf-element-filter-item:first-of-type { display:none; }
Another way to force the users to select one option is to add a Show/Hide in the visualization like this: Hide if UniqueCount([Field]) is greater than 1

Hide Columns in a Grid

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
}

Field Validation in EditorGrid

Let's start with saying that I'm using GXT 2.2.5 on GWT 2.3.0.
My goal is to present the user with a set of data retrieved from a query where he needs to specify a value for one of the fields. As an example, let's say the query returns a list of phone numbers, and the user needs to sepcify the type of number (i.e., Home, Office, Cell, or Pager) each is.
So I'm looking at the EditorGrid as a potential solution. The grid would display the type and number, with a ComboBox attached to the first field through a CellEditor.
The requirement is that the user must select a type for each number. How do I enforce this? I can set allowBlank to false on the ComboBox, but how do I manage it? How do I validate the grid?
I've searched for an answer, but have been unsuccessful.
I suggest the use of the Grid, not the EditorGrid. When using a RowEditor within the Grid the allowBlank validation (or any other fields validator) are fired when the user saves row changes.
Here is a little example in case you are not familiar with the Grid:
ColumnConfig colNombre = new ColumnConfig("name", "Name", 200);
TextField<String> txtNombre = new TextField<String>();
txtNombre.setAllowBlank(false);
txtNombre.getMessages().setBlankText("IT CANT BE EMPTY.");
colNombre.setEditor(new CellEditor(txtNombre));
configs.add(colNombre);
re = new RowEditor<BeanModel>();
re.addListener(Events.AfterEdit, new Listener<RowEditorEvent>() {
public void handleEvent(RowEditorEvent e) {
editar(e);
}
});
re.setClicksToEdit(ClicksToEdit.TWO);
grid = new Grid<BeanModel>(STORE, new ColumnModel(configs));
grid.addPlugin(re);
hope it helps.
Have a SimpleComboBox<String> to store all types of numbers (Home, Office etc). Attach it to the EditorGrid. Set the setEditable(false) property for SimpleComboBox<String>, and make sure that a valid "type" is selected by default in the combo-box (using setValue(...)).
In this way, when your Grid gets rendered, the phone numbers will have type beside them, having a default value selected.
I feel that this is a good approach, rather than having combobox with blank value initially, and then asking user to fill it by showing validation error.

Resources