在弹出窗口更新自定义字段 [英] Update Custom Field on Popup
问题描述
我在更新弹出模型中的自定义字段时遇到问题.
I am having problem in updating custom field in popup model.
我在创建以下 DAC 扩展的客户页面中创建了一个客户字段UsrCustomerNote".
I created a customer field 'UsrCustomerNote' in Customers page which created the following DAC Extension.
namespace PX.Objects.CR
{
public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
{
#region UsrCustomerNote
[PXDBString(1000)]
[PXUIField(DisplayName="Customer Note")]
public virtual string UsrCustomerNote { get; set; }
public abstract class usrCustomerNote : IBqlField { }
#endregion
}
}
我在客户页面中添加了字段控件,如下所示.
And I added field control in Customers page like this.
我的要求是在选择客户时在服务订单页面的新弹出对话框中显示此 CustomerNote 字段值.
My requirement is to display this CustomerNote field value in new popup dialog in Service Orders page when I select the Customer.
首先,我在名为ServiceOrderEntry"的服务订单图形扩展中创建了一个视图名称 CustomerSelector.
First I created a view name CustomerSelector in Graph Extension for Service Orders called 'ServiceOrderEntry'.
public PXFilter<BAccount> CustomerSelector;
所以,我在服务订单页面添加了一个弹出面板.并在弹出窗口中添加了自定义字段.
So, I added a Popup Panel in Service Order page. And added the custom field in popup.
然后我在服务订单页面中为字段 CustomerID 添加了一个 Field_Updated 事件处理程序.这是 ServiceOrderEntry Graph 扩展的完整代码片段.
Then I added an Field_Updated Event Handler for the field CustomerID in Service Orders page. And here is the full code snippet of of ServiceOrderEntry Graph extension.
using System;
using PX.Objects;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;
namespace PX.Objects.FS
{
public class ServiceOrderEntry_Extension : PXGraphExtension<ServiceOrderEntry>
{
#region Event Handlers
public PXFilter<BAccount> CustomerSelector;
protected void FSServiceOrder_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (FSServiceOrder)e.Row;
if (CustomerSelector.AskExt(delegate
{
BAccountEnq bAccountEnq = PXGraph.CreateInstance<BAccountEnq>();
BAccount bAccount = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(bAccountEnq, row.CustomerID);
CustomerSelector.Current = bAccount;
CustomerSelector.Current.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote = (string)bAccount.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote;
/*
* The below one didn't work too
*/
//CustomerSelector.Cache.SetValue<PX.Objects.CR.BAccountExt.usrCustomerNote>(CustomerSelector.Current, (string)bAccount.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote);
CustomerSelector.Update(CustomerSelector.Current);
}) == WebDialogResult.OK)
{
//CODE TO UPDATE THE VALUE IN CUSTOMERS PAGE
}
}
#endregion
}
}
它加载了弹出面板,但 TextField 为空,即使我可以看到该字段的值已在调试模式下更新.
It loads the popup panel but the TextField is empty, even though I can see that the field's value has been updated in debug mode.
我需要帮助来找出我遗漏的东西.
I need the help to find out what I am missing.
推荐答案
我找到了问题所在.对于 Dialog,需要将 LoadOnDemand 属性设置为 true.代码从一开始就很好.感谢 @Samvel Petrosov 对此提供的帮助.
I figured out the problem. It was the LoadOnDemand property that needs to be set to true for Dialog. The code was fine from beginning. Thanks @Samvel Petrosov for your help to this.
这篇关于在弹出窗口更新自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!