用于自定义 table 的 PXSelector 在选择不同记录时不更改记录
PXSelector for custom table not changing records when selecting different record
我一直在努力让它发挥作用,但没有成功。我已经自定义了数十个现有页面并使用了现有数据库 table 的选择器,但无法让选择器为自定义 table.
的 Maint 页面工作
我制作了一个带有表单的自定义页面,并尝试添加一个使用 CD 作为显示的选择器。通过阅读文档并与其他开箱即用的页面进行比较,这就是我想出的。
在我的数据库中,我的 ID 字段是我的 PK 和自动增量 int 不为空,CD 只是一个 nvarchar(10) 不为空
这是我的 DAC 中的 ID 和 CD:
#region ID
[PXDBIdentity()]
[PXUIField(DisplayName = "ID")]
public Int32? ID { get; set; }
public class iD : IBqlField { }
#endregion
#region DesignCD
[PXDBString(10, IsUnicode = true, IsKey = true)]
[PXSelector(typeof(UsrDesign.iD), SubstituteKey = typeof(UsrDesign.designCD))]
public string DesignCD { get; set; }
public class designCD : IBqlField { }
#endregion
我可以使用上一个和下一个按钮在记录之间切换,一切正常,但使用选择器时它不会更改记录。我已经尝试过 commit changes = true 和我能想到的所有其他变体。
有人可以帮忙解决这个看似愚蠢的问题吗?
谢谢!
我在使用 Identity 字段时遇到了类似的问题,我在这方面找不到合适的解决方案。
我们所做的是,我们从 db 和 dac 中删除了身份 属性
//[PXDBIdentity(IsKey = true)]
并且在行持续事件中,如果 ID 为空,我们手动生成下一个 ID
protected virtual void ROW_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
if (e.Row == null) return;
ROW Doc = (ROW)e.Row;
if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert)
{
ROW LastDoc = new ROW();
if (Doc.ID == null || Doc.ID.Equals("<NEW>"))
{
try
{
LastDoc = (ROW)PXSelectGroupBy<ROW, Aggregate<Max<ROW.ID>>>.Select(this);
}
catch { }
if (LastDoc != null)
{
if (LastDoc.ID != null)
Doc.ID = LastDoc.ID + 1;
else
Doc.ID = 1;
}
}
}
}
我不知道这个问题的确切原因,但我们就是这样解决的。希望对你有帮助。
克里斯,
由于选择器属性附加到 CD 属性,请尝试将其定义中的 iD
更改为 designCD
,它应该可以工作:
[PXSelector(typeof(UsrDesign.designCD), SubstituteKey = typeof(UsrDesign.designCD))]
在我的场景中,选择器的问题是由于在表单和页面上的选项卡上使用相同的 DataMember 引起的。我不太明白为什么这是个问题,但创建替代视图 PXSelect>> CurrentDesign 并分配该视图的选项卡可以解决问题。
希望这对以后可能犯同样错误的其他人有所帮助。
感谢大家的帮助。
我一直在努力让它发挥作用,但没有成功。我已经自定义了数十个现有页面并使用了现有数据库 table 的选择器,但无法让选择器为自定义 table.
的 Maint 页面工作我制作了一个带有表单的自定义页面,并尝试添加一个使用 CD 作为显示的选择器。通过阅读文档并与其他开箱即用的页面进行比较,这就是我想出的。
在我的数据库中,我的 ID 字段是我的 PK 和自动增量 int 不为空,CD 只是一个 nvarchar(10) 不为空
这是我的 DAC 中的 ID 和 CD:
#region ID
[PXDBIdentity()]
[PXUIField(DisplayName = "ID")]
public Int32? ID { get; set; }
public class iD : IBqlField { }
#endregion
#region DesignCD
[PXDBString(10, IsUnicode = true, IsKey = true)]
[PXSelector(typeof(UsrDesign.iD), SubstituteKey = typeof(UsrDesign.designCD))]
public string DesignCD { get; set; }
public class designCD : IBqlField { }
#endregion
我可以使用上一个和下一个按钮在记录之间切换,一切正常,但使用选择器时它不会更改记录。我已经尝试过 commit changes = true 和我能想到的所有其他变体。
有人可以帮忙解决这个看似愚蠢的问题吗?
谢谢!
我在使用 Identity 字段时遇到了类似的问题,我在这方面找不到合适的解决方案。
我们所做的是,我们从 db 和 dac 中删除了身份 属性 //[PXDBIdentity(IsKey = true)]
并且在行持续事件中,如果 ID 为空,我们手动生成下一个 ID
protected virtual void ROW_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
if (e.Row == null) return;
ROW Doc = (ROW)e.Row;
if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert)
{
ROW LastDoc = new ROW();
if (Doc.ID == null || Doc.ID.Equals("<NEW>"))
{
try
{
LastDoc = (ROW)PXSelectGroupBy<ROW, Aggregate<Max<ROW.ID>>>.Select(this);
}
catch { }
if (LastDoc != null)
{
if (LastDoc.ID != null)
Doc.ID = LastDoc.ID + 1;
else
Doc.ID = 1;
}
}
}
}
我不知道这个问题的确切原因,但我们就是这样解决的。希望对你有帮助。
克里斯,
由于选择器属性附加到 CD 属性,请尝试将其定义中的 iD
更改为 designCD
,它应该可以工作:
[PXSelector(typeof(UsrDesign.designCD), SubstituteKey = typeof(UsrDesign.designCD))]
在我的场景中,选择器的问题是由于在表单和页面上的选项卡上使用相同的 DataMember 引起的。我不太明白为什么这是个问题,但创建替代视图 PXSelect>> CurrentDesign 并分配该视图的选项卡可以解决问题。
希望这对以后可能犯同样错误的其他人有所帮助。
感谢大家的帮助。