单据类型动态赋值
有时候需要对单据类型字段的值进行控制,比如直接给单据类型字段设置指定的值,或者控制单据类型下拉列表的可选数据范围,此需求需要编写单据插件,对字段枚举集合进行一定的处理,如:
public override void BeforeBindData(EventArgs e)
{
判断执行条件,比如下推和选单不执行
if ((this.View.OpenParameter.Status == OperationStatus.ADDNEW && this.View.OpenParameter.CreateFrom == CreateFrom.Push) || this.View.OpenParameter.CreateFrom == CreateFrom.Draw)
{
BillTypeField billTypeField = this.View.Model.BusinessInfo.GetBillTypeField();
ComboFieldEditor editor = this.View.GetFieldEditor<ComboFieldEditor>(billTypeField.Key, 0);
List<EnumItem> items = billTypeField.BuildEnumList();
List<EnumItem> listItems = new List<EnumItem>();
foreach(var item in items)
{
listItems.Add(new EnumItem(new DynamicObject(EnumItem.EnumItemType)) { EnumId = item.EnumId, Value = item.Value, Caption = item.Caption });
}
editor.SetComboItems(listItems);
this.Model.SetValue(billTypeField.Key, "单据类型内码", 0);
}
.............
}
DynamicFormOpenParameter openPara = this.View.OpenParameter;
if (openPara == null && this.View.ParentFormView != null && this.View.ParentFormView is IListView) {
openPara = this.View.ParentFormView.OpenParameter;
}
if(openPara != null)
{
object objValue = openPara.GetCustomParameter("自定义参数名");
}
取单据界面或父项单据列表的窗口打开参数
单据类型动态赋值
本文2024-09-16 19:01:56发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-25967.html