一、应用场景:
单据体的分组信息只能在BOS设计器中,针对单据体的分组列信息属性进行设置,那么打开就是固定的,此实例可,根据场景应用进行动态改变单据体分组的场景
附:单据体分组本身是表格控件功能分组,该分组不会发送事件到服务端进行查询或者更新数据,只是加载数据后,当前页数据进行分组查看,方便以不同列进行分组展示
二、python插件事例(以采购订单-打开时动态改变分组列为物料名称为分组显示,为参考事例,扩展采购订单单据进行注册python插件)import clr;
clr.AddReference('System');
clr.AddReference('Kingdee.BOS.ServiceHelper');
clr.AddReference('Newtonsoft.Json');
clr.AddReference('Kingdee.BOS.DataEntity');
clr.AddReference('Kingdee.BOS');
from Kingdee.BOS import *;
from Kingdee.BOS.JSON import *;
from Kingdee.BOS.Core import *;
from Kingdee.BOS.Core.Metadata import *;
from Kingdee.BOS.Core.Metadata.ControlElement import *;
from Kingdee.BOS.ServiceHelper import *;
from Newtonsoft.Json.Linq import *;
from Kingdee.BOS.Util import *;
from Kingdee.BOS.Core.DynamicForm import *;
def AfterBindData(e):
ordeentryapprance= this.View.LayoutInfo.GetEntityAppearance("FPOOrderEntry");
#先拿到元数据定义好的分组信息
rangroupinfo = ordeentryapprance.CreateGroupColumnsInfo();
#只拿分组列信息
if rangroupinfo.Count > 0:
groupcol = JSONObject();
for objcol in rangroupinfo:
if objcol.ContainsKey("groupColums"):
groupcol = objcol.DeepClone();
rangroupinfo.Remove(objcol);
break;
#动态另外设置别的列为分组列
newgroup = JSONArray();
newgroupcol = JSONObject();
newgroupcol["fieldKey"] = "FMaterialName";#以物料名称为新的分组列
newgroup.Add(newgroupcol);
#如果多列重复以上3行代码,把列名改为分组列名
#和元数据设定的其他分组信息一起组合
groupcol["groupColums"] = newgroup;
rangroupinfo.Add(groupcol);
this.View.GetControl("FPOOrderEntry").SetCustomPropertyValue("SummaryGroupInfo", rangroupinfo);
this.View.GetControl("FPOOrderEntry").InvokeControlMethod("RebuildGridColumns", None);