如何在选择器查找中显示图像?
How to show images inside selector lookup?
在“销售订单”屏幕上的库存 ID 选择器查找中,将图像与其他列一起显示的最佳方式是什么:
PXGridColumn
Type
属性 设置为 Icon
用于显示 PXGrid 容器内的图像:
<px:PXGridColumn DataField="ImageUrl" Width="300px" Type="Icon" />
此类栏目能够显示来自 2 个来源的图像:
精灵
row.ImageUrl = string.IsNullOrEmpty(row.ImageUrl) ? "main@Fail" : "main@Success";
网址:
row.ImageUrl = @"http://www.acumatica.asia/acumaticawwwsite-acumaticainc.netdna-ssl.com/wp-content/uploads/2014/09/acumatica-2.png";
要在库存 ID 选择器查找中添加 Icon
类型的列,应该:
为 SOLine DAC 声明扩展 class 并扩展清单 ID 选择器的列列表:
[PXNonInstantiatedExtension]
public class SO_SOLine_ExistingColumn : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region InventoryID
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.IN.InventoryItem.inventoryCD),
typeof(PX.Objects.IN.InventoryItem.descr),
typeof(PX.Objects.IN.InventoryItem.itemClassID),
typeof(PX.Objects.IN.InventoryItem.itemStatus),
typeof(PX.Objects.IN.InventoryItem.itemType),
typeof(PX.Objects.IN.InventoryItem.baseUnit),
typeof(PX.Objects.IN.InventoryItem.salesUnit),
typeof(PX.Objects.IN.InventoryItem.purchaseUnit),
typeof(PX.Objects.IN.InventoryItem.basePrice),
typeof(PX.Objects.IN.InventoryItem.imageUrl))]
public int? InventoryID { get; set; }
#endregion
}
对于新列,将 Type
属性 值设置为 Icon
:
<px:PXSegmentMask ID="edInventoryID" runat="server" DataField="InventoryID">
<GridProperties>
<Columns>
<px:PXGridColumn DataField="ImageUrl" Type="Icon" Width="300px" AutoGenerateOption="Add" />
</Columns>
</GridProperties>
</px:PXSegmentMask>
然而,这似乎不足以在选择器查找中显示附加到库存项目的图像。我们接下来的步骤是为 InventoryItem DAC 定义一个未绑定的自定义字段,并使用有效的 URL 填充它以显示附加图像。
请注意,下面的示例可能会导致性能显着下降。在现实生活中,您必须使用缩小版本的图片(缩略图)和存储 URL 以通过 Acumatica 数据库中的自定义数据库绑定字段访问它们。
为 InventoryItem DAC 实施扩展 class 并声明未绑定的 ThumbnailURL 字段以存储附加图像的 URL:
public class InventoryItemExt : PXCacheExtension<InventoryItem>
{
public abstract class thumbnailURL : IBqlField
{ }
[PXString]
public string ThumbnailURL { get; set; }
}
在 SOOrderEntry BLC 扩展中,订阅 RowSelecting 处理程序并使用有效 URL 填充未绑定的 ThumbnailURL 字段以显示附加图像:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public override void Initialize()
{
Base.RowSelecting.AddHandler<InventoryItem>(InventoryItemRowSelecting);
}
public void InventoryItemRowSelecting(PXCache sender, PXRowSelectingEventArgs e)
{
var row = e.Row as InventoryItem;
if (row != null && !string.IsNullOrEmpty(row.ImageUrl))
{
Guid[] files = PXNoteAttribute.GetFileNotes(sender, e.Row);
var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
foreach (Guid fileID in files)
{
PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
if (fi.FullName == row.ImageUrl || fi.Name == row.ImageUrl)
{
row.GetExtension<InventoryItemExt>().ThumbnailURL =
ControlHelper.GetAttachedFileUrl(null, fileID.ToString());
break;
}
}
}
}
}
将 ThumbnailURL 列的 Type
属性 设置为 Icon
:
<px:PXSegmentMask CommitChanges="True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" >
<GridProperties>
<Columns>
<px:PXGridColumn DataField="ThumbnailURL" Width="300px" AutoGenerateOption="Add" Type="Icon" />
</Columns>
</GridProperties>
</px:PXSegmentMask>
在“销售订单”屏幕上的库存 ID 选择器查找中,将图像与其他列一起显示的最佳方式是什么:
PXGridColumn
Type
属性 设置为 Icon
用于显示 PXGrid 容器内的图像:
<px:PXGridColumn DataField="ImageUrl" Width="300px" Type="Icon" />
此类栏目能够显示来自 2 个来源的图像:
精灵
row.ImageUrl = string.IsNullOrEmpty(row.ImageUrl) ? "main@Fail" : "main@Success";
网址:
row.ImageUrl = @"http://www.acumatica.asia/acumaticawwwsite-acumaticainc.netdna-ssl.com/wp-content/uploads/2014/09/acumatica-2.png";
要在库存 ID 选择器查找中添加 Icon
类型的列,应该:
为 SOLine DAC 声明扩展 class 并扩展清单 ID 选择器的列列表:
[PXNonInstantiatedExtension] public class SO_SOLine_ExistingColumn : PXCacheExtension<PX.Objects.SO.SOLine> { #region InventoryID [PXMergeAttributes(Method = MergeMethod.Append)] [PXCustomizeSelectorColumns( typeof(PX.Objects.IN.InventoryItem.inventoryCD), typeof(PX.Objects.IN.InventoryItem.descr), typeof(PX.Objects.IN.InventoryItem.itemClassID), typeof(PX.Objects.IN.InventoryItem.itemStatus), typeof(PX.Objects.IN.InventoryItem.itemType), typeof(PX.Objects.IN.InventoryItem.baseUnit), typeof(PX.Objects.IN.InventoryItem.salesUnit), typeof(PX.Objects.IN.InventoryItem.purchaseUnit), typeof(PX.Objects.IN.InventoryItem.basePrice), typeof(PX.Objects.IN.InventoryItem.imageUrl))] public int? InventoryID { get; set; } #endregion }
对于新列,将
Type
属性 值设置为Icon
:<px:PXSegmentMask ID="edInventoryID" runat="server" DataField="InventoryID"> <GridProperties> <Columns> <px:PXGridColumn DataField="ImageUrl" Type="Icon" Width="300px" AutoGenerateOption="Add" /> </Columns> </GridProperties> </px:PXSegmentMask>
然而,这似乎不足以在选择器查找中显示附加到库存项目的图像。我们接下来的步骤是为 InventoryItem DAC 定义一个未绑定的自定义字段,并使用有效的 URL 填充它以显示附加图像。
请注意,下面的示例可能会导致性能显着下降。在现实生活中,您必须使用缩小版本的图片(缩略图)和存储 URL 以通过 Acumatica 数据库中的自定义数据库绑定字段访问它们。
为 InventoryItem DAC 实施扩展 class 并声明未绑定的 ThumbnailURL 字段以存储附加图像的 URL:
public class InventoryItemExt : PXCacheExtension<InventoryItem> { public abstract class thumbnailURL : IBqlField { } [PXString] public string ThumbnailURL { get; set; } }
在 SOOrderEntry BLC 扩展中,订阅 RowSelecting 处理程序并使用有效 URL 填充未绑定的 ThumbnailURL 字段以显示附加图像:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry> { public override void Initialize() { Base.RowSelecting.AddHandler<InventoryItem>(InventoryItemRowSelecting); } public void InventoryItemRowSelecting(PXCache sender, PXRowSelectingEventArgs e) { var row = e.Row as InventoryItem; if (row != null && !string.IsNullOrEmpty(row.ImageUrl)) { Guid[] files = PXNoteAttribute.GetFileNotes(sender, e.Row); var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>(); foreach (Guid fileID in files) { PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID); if (fi.FullName == row.ImageUrl || fi.Name == row.ImageUrl) { row.GetExtension<InventoryItemExt>().ThumbnailURL = ControlHelper.GetAttachedFileUrl(null, fileID.ToString()); break; } } } } }
将 ThumbnailURL 列的
Type
属性 设置为Icon
:<px:PXSegmentMask CommitChanges="True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" > <GridProperties> <Columns> <px:PXGridColumn DataField="ThumbnailURL" Width="300px" AutoGenerateOption="Add" Type="Icon" /> </Columns> </GridProperties> </px:PXSegmentMask>