多类别基础资料列表下拉选项跟下拉列表枚举选项是一样控制的,只是它的枚举值来源为可选基础资料,每项基础资料就是一个枚举值,此枚举值包含基础资料的formId,名称等。下面是使用文本值跟枚举项中的value是否包含来显示多类别基础资料的一段代码示例,当文本值为空的时候显示所有可选基础资料,不为空则显示包含其的可选基础资料。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.List.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.ConvertElement;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Metadata.ElementMetadata;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
namespace Kingdee.BOS.TestPlugIn
{
[HotUpdate]
[Description("单据A表单插件")]
public class BillAFormPlugIn : AbstractBillPlugIn
{
/// <summary>
/// 值改变事件
/// </summary>
/// <param name="e"></param>
public override void DataChanged(DataChangedEventArgs e)
{
base.DataChanged(e);
if (e.Field.Key.EqualsIgnoreCase("F_KKK_Text")) //文本值更新
{
this.UpdateItemClassTypeField();
}
}
/// <summary>
/// 数据绑定事件
/// </summary>
/// <param name="e"></param>
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
this.UpdateItemClassTypeField();
}
/// <summary>
/// 更新多类别资料列表
/// </summary>
private void UpdateItemClassTypeField()
{
var textValue = ObjectUtils.Object2String(this.View.Model.GetValue("F_KKK_Text")) ; //得到文本值
var itemClass = this.View.BillBusinessInfo.GetField("F_Jac_ItemClass") as ItemClassTypeField; //多类别基础资料列表
var itemDynObjs = itemClass.EnumObject["Items"] as DynamicObjectCollection; //多类别基础资料列表枚举项
//根据文本值过滤枚举项
List<EnumItem> lstItems = new List<EnumItem>();
lstItems.Add(new EnumItem());//可以先加空项
var items = itemDynObjs.Where(x => ObjectUtils.Object2String(x["Value"]).Contains(textValue)).Select(x => (EnumItem)x).ToList();
lstItems.AddRange(items);
var comboList = this.View.GetFieldEditor<ComboFieldEditor>("F_Jac_ItemClass", 0);
if (comboList != null)
{
comboList.SetComboItems(lstItems); //给前端多类别基础资料列表控件赋值
}
}
}
}
推荐阅读