I am trying to hide these duplicate inventory ID values for the "price" and "Cost" lines (when one "adds" an item to the grid it creates three lines), but the selector description still appears.
How can I just make these value come up blank in the grid?
Even better, how can I disable a link command so if someone inadvertently clicks then it wont link to the stock item screen?
Here is my code thus far:
protected void _(Events.FieldSelecting<FPPriceSheetDetail, FPPriceSheetDetail.inventoryID> e)
{
if (e.Row is null) return;
if (e.Row.RowType == FPPriceSheetRowType.BreakQty) return;
var state = PXFieldState.CreateInstance(e.ReturnState, typeof(string), true, false, 1, null, null, null, nameof(FPPriceSheetDetail.inventoryID));
state.SelectorMode = PXSelectorMode.TextMode;
state.DescriptionName = "";
state.ValueField = "";
state.Visibility = PXUIVisibility.Visible;
state.Visible = true;
e.ReturnState = state;
e.ReturnValue = "";
}
I would rather review the pxSelector and in the condition only show 1-row type - this will remove the duplicates. The point of the selector is to select one of the values within the result - assuming all the information the selector are selectable.
Related
Example:
As per the Below screenshot, i have to combine below two grids into one grid and the first grid(query list) will display as it is and the second grid values should show as drop down for the respective query.
Samplegridsimage
when i tried to use field selecting event, it is loading all vales from second grid but i need only 3 values for fuel type value and for others different drop down.
can anyone suggest how to get only particular values in the drop down.
protected virtual void KNRWTAXQueries_Response_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
KNRWTAXQueries doc = e.Row as KNRWTAXQueries;
if (doc == null) return;
List<string> Responsevalues = new List<string>();
List<string> ResponseLables = new List<string>();
if (QueryList.Current != null)
{
if (Base.Transactions.Current != null)
{
foreach (KNRWTAXQueries queries in PXSelect<KNRWTAXQueries, Where<KNRWTAXQueries.nonStockItemID, Equal<Required<APTran.inventoryID>>>>.Select(Base, doc.NonStockItemID))
{
foreach (KNRWTAXResponse response in PXSelect<KNRWTAXResponse, Where<KNRWTAXResponse.tAXQueID, Equal<Required<KNRWTAXResponse.tAXQueID>>>>.
Select(Base, queries.Taxqueid))
{
Responsevalues.Add(response.Response);
ResponseLables.Add(response.Response);
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 255, true, typeof(KNRWTAXQueries.response).Name, false, 1, string.Empty, Responsevalues.ToArray(),
ResponseLables.ToArray(), true, null);
}
}
}
}
// ((PXStringState)e.ReturnState).MultiSelect = false;
}
You can use RowSelected event of the row to set the list. No need to use FieldSelecting (however you can use field selecting too)
You should use PXStringListAttribute.SetList method to set new list instead of using string state
You should set MatrixMode=true in the aspx grid row so that list is recreated for each row (oterwise the list will be the same for all rows)
<px:PXGridColumn DataField="OrigTranType" Type="DropDownList" MatrixMode="true" />
When using the collapsed interface on the sales order (AKA the arrow tiny button to the right) is it possible to do one of the following:
Change the fields it displays (eg: right now I am showing some labels for the fields below in those columns). It would be truly amazing if when I click that, I could move some of the fields from the first column to the top 2 rows. Thus, I would move the most important data from the first column to the header.
Alternately, can you make the top be 3-4 rows instead of just 2, or is that hard coded in?
Thanks in advance.
Form container Autosize element and MinHeight/MinHeightLimit properties does affect the behavior of the expander but I haven't found a way to achieve the desired functionality with those.
This is the code which generates the form panel Div element:
/// <summary>
/// Create the content division control.
/// </summary>
private WebControl CreateContentDiv()
{
WebControl div = this.TemplateContainer;
this.hasStaticContent = this.AutoSizeWindow;
if (hasStaticContent) foreach (Control c in div.Controls)
{
IAutoSizedControl sc = c as IAutoSizedControl;
if (sc != null && sc.AutoSize.Enabled) { hasStaticContent = false; break; }
var wc = c as WebControl;
var hc = c as System.Web.UI.HtmlControls.HtmlControl;
if (wc != null || hc != null)
{
string pos = (wc != null) ? wc.Style["position"] : hc.Style["position"];
if (pos == "absolute") { hasStaticContent = false; break; }
}
}
if (!hasStaticContent && (!ControlHelper.GetHeight(this).IsEmpty || this.AutoSize.Enabled))
div.Height = Unit.Percentage(100);
// mark division as editable region
if (this.DesignMode)
div.Attributes.Add(DesignerRegion.DesignerRegionAttributeName, "0");
return div;
}
I also found elements that suggests the 2 row value is hardcoded for the purpose of showing the expander control (if content height is taller then 2 row show expander control):
/// <summary>
///
/// </summary>
protected override void OnLoad(EventArgs e)
{
if (this.Page != null && !this.Page.IsCallback)
{
var gen = (PXLayoutGenerator)this.TemplateContainer;
gen.CreateStackByRules();
if (!this.CaptionAsLink && !this.AutoSize.Enabled)
{
if (this.AllowCollapse == null && gen.Rows > 2) this.AllowCollapse = true;
//if (this.AllowCollapse == true && !this.CaptionVisible) this.CreateCollapseImage();
}
}
base.OnLoad(e);
}
With JavaScript it would possible to roll your own logic to control the UI layer.
Setting the TabPanel style height property will achieve the desired rendering and it should be possible to hook the expander events too:
document.getElementById('ctl00_phF_form_t0').style.height = '117px';
To re-order the editor control based on the form collapsed state is a bit more difficult depending on the layout but can be achieved similarly by setting the CSS display property:
var isVisible = false;
document.getElementById(alse'ctl00_phF_form_t0_edCustomerID_text').parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.style.display = isVisible ? 'block' : 'none';
I have a processing page that I want to automatically select certain types of rows. I can set the select checkbox to true, but what property needs to be set on the row so that the process button will act on it? Right now nothing happens unless I check another row.
public void EDASNShipProj_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
PXUIFieldAttribute.SetDisplayName<EDASNShipProj.customerLocationID>(sender, "Ship Location");
var row = (EDASNShipProj)e.Row;
if ( row.UsrTruckNbr != 0 )
row.Selected = true;
PXUIFieldAttribute.SetVisible<SOShipment.selected>(sender, null, true);
}
I figured this out after searching the base source code for ".Selected=true". I found several places which included two extra lines. I added them to my condition and now the checked rows are included in the process list. Hopefully this will help others.
if (row.UsrTruckNbr != 0)
{
row.Selected = true;
sender.IsDirty = true;
sender.SetStatus(row, PXEntryStatus.Updated);
}
I am trying to update the Inventory Item ImageUrl if it is found to be null with some conditions. I have added a Usr field called UsrStyleImg to the Item Class screen. This field is for a basic image of an item and it is stored in the database. The functionality I want is if the Inventory Item does not have an image in the ImageUrl then it will default to the UsrStyleImg that is connected with the ItemClassID. ItemClassID is also found on the Stock Item Screen. Here is the code I have in the InventoryItemMaint graph:
protected void InventoryItem_ImageUrl_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
var row = (InventoryItem)e.Row;
if (row == null) return;
var item = (INItemClass)PXSelect<INItemClass, Where<INItemClass.itemClassID, Equal<Current<InventoryItem.itemClassID>>>>.Select(Base, row.ItemClassID);
var image = PXSelect<InventoryItem, Where<InventoryItem.imageUrl, Equal<Current<InventoryItem.imageUrl>>>>.Select(Base, row.ImageUrl);
if (image != null)
return;
else {
e.NewValue = item.GetExtension<INItemClassExt>().UsrStyleImg;
}
}
The code compiles fine but when I test with an Item that has an Item Class attached to it with an image in the INItemClass table called UsrStyleImg it does not populate to the imageUrl found in the Inventory Item table or the Stock Item screen. I have also tried this with FieldSelecting and using the e.ReturnValue with still the same results.
If I need more clarification please let me know.
Try using a RowSelecting Event
protected virtual void InventoryItem_RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
{
InventoryItem row = e.Row as InventoryItem;
//Extra checks to prevent infinite loops
if (row != null && !string.IsNullOrWhiteSpace(row.InventoryCD) && Base.Item.Cache.GetStatus(row) == PXEntryStatus.Notchanged)
{
if (!string.IsNullOrWhiteSpace(row.ItemClassID))
{
//You must always use a PXConnectionScope if Selecting during RowSelecting
using (new PXConnectionScope())
{
//If you're going to pass in a value in .Select, use Required instead of Current.
INItemClass itemClass = PXSelectReadonly<INItemClass, Where<INItemClass.itemClassID, Equal<Required<INItemClass.itemClassID>>>>.Select(Base, row.ItemClassID);
if (itemClass != null && string.IsNullOrWhiteSpace(row.ImageUrl))
{
INItemClassExt itemClassExt = itemClass.GetExtension<INItemClassExt>();
//To prevent unneeded update if it's blank
if (!string.IsNullOrWhiteSpace(itemClassExt.UsrStyleImg))
{
row.ImageUrl = itemClassExt .UsrStyleImg;
//Force set the status in the Cache, otherwise it infinite loops
Base.Item.Cache.SetStatus(row, PXEntryStatus.Updated);
Base.Item.Update(row);
}
}
}
}
}
}
I have added a field to the Prepare Replenishment form that needs to be updated when a user selects a row in the Replenishment Item grid. How do I access the field. I know it is in the INReplenishmentFilterExt but I can't figure out how to get access to the extension.
Edit #1: I am able to get the value of the field but it does not update on the screen when I use cache.SetValue. I am trying to update this filter extension field from inside of the Selected event handler.
protected void INReplenishmentItem_Selected_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e)
{
var row = (INReplenishmentItem)e.Row;
if (row == null)
return;
INReplenishmentFilter filter = Base.Filter.Current;
INReplenishmentFilterExt filterExt = PXCache<INReplenishmentFilter>.GetExtension<INReplenishmentFilterExt>(filter);
decimal poAmount = filterExt.UsrPOAmount.HasValue ? filterExt.UsrPOAmount.Value : 0;
decimal lastPrice = pvi.LastPrice.HasValue ? pvi.LastPrice.Value : 0;
decimal newPOAmount = poAmount + lastPrice;
cache.SetValue<INReplenishmentFilterExt.usrPOAmount>(filterExt, newPOAmount);
}
You cannot set the value of the Filter using the Cache of INReplenishmentItem.
I have edited my answer, the code below should work.
//Always use virtual methods for Event Handlers
protected virtual void INReplenishmentItem_Selected_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
{
//Try not to use vars. Especially when you know the Type of the object
INReplenishmentItem row = e.Row as INReplenishmentItem;
if (row != null)
{
INReplenishmentFilter filter = Base.Filter.Current;
INReplenishmentFilterExt filterExt = PXCache<INReplenishmentFilter>.GetExtension<INReplenishmentFilterExt>(filter);
decimal poAmount = filterExt.UsrPOAmount ?? 0;
decimal lastPrice = pvi.LastPrice ?? 0;//Not sure what pvi is
decimal newPOAmount = poAmount + lastPrice;
//"sender" is the cache that specifically stores the datatype of row
//Therefor you cannot use it to update records of a different datatype
//You also should not pass an Extension into the argument that should be the row object you are trying to update
Base.Filter.Cache.SetValueExt<INReplenishmentFilterExt.usrPOAmount>(filter, newPOAmount);
}
}