二开案例.表单插件.设置单据体分组汇总列

【应用场景】
设置单据体分组汇总列。
【案例演示】
新建动态表单,演示给单据体设置分组汇总列。

【实现步骤】
<1>编写表单插件,代码如下。
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Metadata.GroupElement;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// <summary>
/// 【表单插件】设置单据体分组汇总列
/// </summary>
[Description("【表单插件】设置单据体分组汇总列"), HotUpdate]
public class SetSummaryGroupInfoFormPlugIn : AbstractDynamicFormPlugIn
{
/// <summary>
/// 单据体标识
/// </summary>
private const string EntityKey = "F_Jac_Entity";
public override void OnSetBusinessInfo(SetBusinessInfoArgs e)
{
base.OnSetBusinessInfo(e);
InitGroupColumnInfo(this.View.BillBusinessInfo, EntityKey);
}
public override void BarItemClick(BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey.EqualsIgnoreCase("test"))
{
BindData();
}
else if (e.BarItemKey.EqualsIgnoreCase("test1"))
{
// 只汇总
SetSummaryGroupInfo(this.View, EntityKey, null, new[] { "F_Jac_Integer" });
}
else if (e.BarItemKey.EqualsIgnoreCase("test2"))
{
// 分组+汇总
SetSummaryGroupInfo(this.View, EntityKey, new[] { "F_Jac_Text" }, new[] { "F_Jac_Integer1", "F_Jac_Integer2" });
}
else if (e.BarItemKey.EqualsIgnoreCase("test3"))
{
// 取消分组汇总
SetSummaryGroupInfo(this.View, EntityKey, null, null);
}
}
/// <summary>
/// 动态创建单据体数据包
/// </summary>
private void BindData()
{
this.Model.DeleteEntryData(EntityKey);
this.Model.BatchCreateNewEntryRow(EntityKey, 10);
// 随机生成10行数据
for (var i = 0; i < this.Model.GetEntryRowCount(EntityKey); i++)
{
this.Model.SetValue("F_Jac_Text", Guid.NewGuid().ToString()[0], i);
this.Model.SetValue("F_Jac_Integer", new Random(Guid.NewGuid().GetHashCode()).Next(100, 999), i);
this.Model.SetValue("F_Jac_Integer1", new Random(Guid.NewGuid().GetHashCode()).Next(1000, 9999), i);
this.Model.SetValue("F_Jac_Integer2", new Random(Guid.NewGuid().GetHashCode()).Next(10000, 99999), i);
}
this.View.UpdateView(EntityKey);
}
/// <summary>
/// 设置单据分组汇总
/// </summary>
/// <param name="view">动态表单的视图</param>
/// <param name="entityKey">单据体标识</param>
/// <param name="groupFieldKeys">分组字段标识的集合</param>
/// <param name="sumFieldKeys">汇总字段标识的集合</param>
private void SetSummaryGroupInfo(IDynamicFormView view, string entityKey, string[] groupFieldKeys, string[] sumFieldKeys)
{
var jsObj = new JSONObject();
#region 设置分组字段
var jsGroupFields = new JSONArray();
//jsObj.Put("groupColums", jsGroupFields);
if (groupFieldKeys != null)
{
foreach (var fieldKey in groupFieldKeys)
{
var groupField = view.BillBusinessInfo.GetField(fieldKey);
if (groupField == null)
{
continue;
}
var jsGroupField = new JSONObject();
jsGroupField["fieldKey"] = groupField.Key.ToUpper();
jsGroupFields.Add(jsGroupField);
}
}
jsObj.Put("groupColums", jsGroupFields);
if (jsGroupFields.Count == 0)
{
view.GetControl<EntryGrid>(entityKey).InvokeControlMethod("RebuildGridColumns", null);
}
二开案例.表单插件.设置单据体分组汇总列
【应用场景】设置单据体分组汇总列。【案例演示】新建动态表单,演示给单据体设置分组汇总列。【实现步骤】<1>编写表单插件,代码如下。usi...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇



