我正在努力在选择 InventoryID 时在销售订单行上为文档详细信息制作缩略图。然而,每当我在行中选择 InventoryID 时,图像不会填充到网格中。这是我到目前为止所拥有的:
DAC 扩展:
namespace PX.Objects.IN
{
public class InventoryItemExt : PXCacheExtension<InventoryItem>
{
#region ThumbnailURL
public abstract class thumbnailURL : IBqlField
{ }
[PXString]
public string ThumbnailURL { get; set; }
#endregion
}
}
代码扩展:
using PX.Data;
using PX.Objects.SO;
using System;
using PX.Objects.IN;
using PX.Web.UI;
namespace Combined
{
public class SOLineExt : PXCacheExtension<SOLine>
{
#region ThumbnailURL
public abstract class thumbnailURL : IBqlField
{ }
[PXString]
public string ThumbnailURL { get; set; }
#endregion
}
public class SOOrderEntryExt: PXGraphExtension<SOOrderEntry>
{
public void SOLine_RowSelecting(PXCache sender, PXRowSelectingEventArgs e,PXRowSelecting baseMethod)
{
baseMethod.Invoke(sender, e);
if(e.Row!=null)
{
var row = e.Row as SOLine;
if (row.InventoryID != null)
{
InventoryItem currentLineItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(this.Base, row.InventoryID);
if (row != null && !string.IsNullOrEmpty(currentLineItem.ImageUrl))
{
if(currentLineItem.StkItem==true)
{
InventoryItemMaint inventoryItemMaint = PXGraph.CreateInstance<InventoryItemMaint>();
Guid[] files = PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache, currentLineItem);
var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
foreach (Guid fileID in files)
{
PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
if (fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
{
row.GetExtension<SOLineExt>().ThumbnailURL = ControlHelper.GetAttachedFileUrl(null, fileID.ToString());
break;
}
}
}
else
{
NonStockItemMaint inventoryItemMaint = PXGraph.CreateInstance<NonStockItemMaint>();
Guid[] files = PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache, currentLineItem);
var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
foreach (Guid fileID in files)
{
PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
if (fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
{
row.GetExtension<SOLineExt>().ThumbnailURL = ControlHelper.GetAttachedFileUrl(null, fileID.ToString());
break;
}
}
}
}
}
}
}
}
}
ASPX 代码:
网格中的代码:
<px:PXGridColumn DataField="ThumbnailURL" Width="300px" Type="Icon" />
InventoryID SegmentMask 上的代码:
<px:PXSegmentMask CommitChanges="True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" >
<GridProperties>
<Columns>
<px:PXGridColumn Type="Icon" DataField="ThumbnailURL" Width="300px" AutoGenerateOption="Add" />
</Columns>
</GridProperties>
</px:PXSegmentMask>
我确实找到了一篇关于将图像添加到 InventoryID 选择器的帖子,它有一种不同的方法将图像添加到该网格,这同样适用于这里吗?这是另一篇文章:如何在选择器查找中显示图像? https://stackoverflow.com/questions/39926127/how-to-show-images-inside-selector-lookup
我已经更改了上面的代码以匹配其他帖子,但现在我收到此错误:
\App_RuntimeCode\SOOrderEntry.cs(61): error CS0103: The name 'ControlHelper' does not exist in the current context
\App_RuntimeCode\SOOrderEntry.cs(61): error CS0103: The name 'ControlHelper' does not exist in the current context
Adding code from the first answer below but now the grid column is showing up blank:
更新1: FIXED我已经重做了上面的所有代码来回答 1,并添加了上面帖子中 Ruslan 的答案中的代码。屏幕截图仍然一样。
Update 2:
I have got everything working or so it seemed. I am now receiving this error only sometimes and I'm not sure what the cause is. Ignore the CustomerID error that is because their credit balance is overdue.