2017-01-09 68 views
0

我在库存项目页面上创建了一个视图,该视图显示与正在查看的项目具有相同项目类别的所有项目。该视图正确显示,但当前属性不正确。出于某种原因,relatedItems.Current记录始终是当前页面上的项目,而不是在网格中选择的项目。自定义视图的当前属性没有正确更新

我有ASPX页面的回调函数和InventoryCD LinkCommand调用这个函数。奇怪的是,我在“项目类别”屏幕上显示了相同的代码,并且它完美地工作。

我自定义视图的Current属性始终是被点击的记录。我已将网格的SyncPosition设置设置为true。有没有问题,因为我在InventoryItem上引用InventoryItem?由于

public class InventoryItemMaint_Extension : PXGraphExtension<InventoryItemMaint> 
{ 

    #region Event Handlers 

    public PXSelectReadonly<InventoryItem, Where<InventoryItem.itemClassID, Equal<Current<InventoryItem.itemClassID>>, And<InventoryItem.inventoryID, NotEqual<Current<InventoryItem.inventoryID>>>>> relatedItems; 

    public PXAction<InventoryItem> ViewCurrentItem; 

    [PXButton] 
    protected virtual void viewCurrentItem() 
    { 

     InventoryItem row = relatedItems.Current; 

     // Create the instance of the destination graph 
     InventoryItemMaint graph = PXGraph.CreateInstance<InventoryItemMaint>(); 
     graph.Item.Current = row; 

     if (graph.Item.Current != null) 
     { 
      throw new PXRedirectRequiredException(graph, true, "Item"); 
     } 
    } 
} 

回答

0

请确认如果您在页面中指定DependOnGrid属性为您的操作: -

<CallbackCommands> 
    ... 
    <px:PXDSCallbackCommand Name="ViewCurrentItem" Visible="true" DependOnGrid="RelatedGridID" /> 
</CallbackCommands> 

属性,T200培训材料解释

enter image description here

替代选择将要利用PXSelector的AllowEdit - 您不需要自定义操作。

<px:PXGrid … > 
    <Levels> 
     <px:PXGridLevel …> 
     <Columns> 
     … 
     </Columns> 
     <RowTemplate> 
      <px:PXSegmentMask runat="server" ID="CstPXSegmentMask2" DataField="InventoryCD" AllowEdit="True" />            
     </RowTemplate> 
     </px:PXGridLevel> 
    </Levels> 
</px:PXGrid> 

要在同一页面更改的项目,

每个数据视图应该是指一种独特的主数据访问类(DAC),除非你想显示在同一个数据记录多个容器控件。因此,您需要创建一个新的DAC来表示继承自InventoryItem的相关项目,并为BQL语句中使用的派生类的数据字段定义新的抽象类。

[Serializable] 
public class RelatedInventoryItem : InventoryItem 
{ 
    public new abstract class inventoryID : IBqlField { }; 

    public new abstract class itemClassID : IBqlField { }; 
} 

和你的数据视图应该是

public PXSelectReadonly<RelatedInventoryItem, 
         Where<RelatedInventoryItem.itemClassID, 
           Equal<Current<InventoryItem.itemClassID>>, 
          And<RelatedInventoryItem.inventoryID, 
          NotEqual<Current<InventoryItem.inventoryID>>>>> 
         relatedItems; 
0

@DChhapgar是的,我有DependOnGrid正确设置。这里的所有相关代码:

<px:PXDSCallbackCommand Name="ViewRelatedItems" Visible="true" DependOnGrid="relatedItemsGridID" /></CallbackCommands> 
.... 
    <px:PXTabItem Text="Related Items"> 
    <Template> 
     <px:PXGrid runat="server" ID="relatedItemsGridID" SkinID="DetailsInTab" Width="100%" SyncPosition="True" DataSourceID="ds" > 
      <Levels> 
       <px:PXGridLevel DataMember="relatedItems"> 
        <Columns> 
         <px:PXGridColumn DataField="InventoryCD" Width="100" LinkCommand="ViewRelatedItems"/> 
         <px:PXGridColumn DataField="InventoryID" Width="100" /> 
         <px:PXGridColumn DataField="ItemClassID" Width="100" /> 
         <px:PXGridColumn DataField="Descr" Width="200" /> 
         <px:PXGridColumn DataField="ItemStatus" Width="100" /> 
         <px:PXGridColumn DataField="ItemType" Width="100" /> 
         <px:PXGridColumn DataField="KitItem" Width="60" /></Columns> 
        </px:PXGridLevel></Levels> 
      <AutoSize Enabled="True" MinHeight="200" /> 
      <Mode AllowAddNew="False" AllowDelete="False" AllowUpdate="False" /></px:PXGrid></Template></px:PXTabItem> 
.... 

使用PXSelectorAllowEdit的作品,但我想改变的项目在同一个页面,因此,最好的用户会点击该项目时,库存ID /库存CD标题中的字段将填充单击的项目,并提交更改。

+0

我已更新原始答案。 – DChhapgar