二开方案.动态干预过滤界面中可选择的字段
【场景】
干预过滤界面中过滤条件、高级过滤、排序、显示隐藏列界面中的可选择字段。
【示例】
在不修改过滤模型的情况下,以动态隐藏可选择的字段为例(动态新增可根据示例反推)。
示例代码如下:
using System.ComponentModel;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.CommonFilter.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Model.CommonFilter;
using Kingdee.BOS.Util;
namespace Kingdee.BOS.TestPlugIn
{
/// <inheritdoc />
[HotUpdate]
[Description("修改过滤方案条件")]
public class TestBillOrgIsolationFilterPlugIn : AbstractCommonFilterPlugIn
{
/// <inheritdoc />
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
var filterModel = (ICommonFilterModel)this.Model;
JSONObject removeJson = null;
#region 过滤条件
var filterGrid = this.View.GetControl<FilterGrid>(CommonFilterConst.ControlKey_FilterGrid);
var filterObject = filterModel.FilterObject;//过滤条件对象
var removeField = filterObject.GetFilterField("FText");
var allFieldJson = filterObject.GetAllFilterFieldList();
foreach (JSONObject jsonObject in allFieldJson)
{
if (jsonObject["FieldName"].GetString().EqualsIgnoreCase(removeField.FieldName))
{
removeJson = jsonObject;
}
}
if (removeJson != null)
{
allFieldJson.Remove(removeJson);
}
if (filterGrid != null)
{
filterGrid.SetFilterFields(allFieldJson);
}
#endregion
#region 高级过滤
var batchFilterGrid = this.View.GetControl<FilterGrid>(CommonFilterConst.ControlKey_BatchFilterGrid);
var batchFilterObject = filterModel.BatchFilterObject;//高级过滤对象
allFieldJson = batchFilterObject.GetAllFilterFieldList();
foreach (JSONObject jsonObject in allFieldJson)
{
if (jsonObject["FieldName"].GetString().EqualsIgnoreCase(removeField.FieldName))
{
removeJson = jsonObject;
}
}
if (removeJson != null)
{
allFieldJson.Remove(removeJson);
}
if (batchFilterGrid != null)
{
batchFilterGrid.SetFilterFields(allFieldJson);
}
#endregion
#region 排序
var sortGrid = this.View.GetControl<SortSet>(CommonFilterConst.ControlKey_Sort);
var sortObject = ((FilterModel)filterModel).SortObject;//排序对象
allFieldJson = sortObject.GetAllSortFields();
foreach (JSONObject jsonObject in allFieldJson)
{
if (jsonObject["FieldName"].GetString().EqualsIgnoreCase(removeField.FieldName))
{
removeJson = jsonObject;
}
}
if (removeJson != null)
{
allFieldJson.Remove(removeJson);
}
if (sortGrid != null)
{
sortGrid.SetSortFields(allFieldJson);
}
#endregion
#region 显示隐藏
var showHideGrid = this.View.GetControl<FieldShowHide>(CommonFilterConst.ControlKey_FieldShowHide);
var columnObject = ((FilterModel)filterModel).ColumnObject;//显示隐藏列对象
allFieldJson = columnObject.GetAllFieldList(true);
foreach (JSONObject jsonObject in allFieldJson)
{
if (jsonObject["FieldName"].GetString().EqualsIgnoreCase(removeField.FieldName))
{
removeJson = jsonObject;
}
}
if (removeJson != null)
{
allFieldJson.Remove(removeJson);
}
var rowJson = columnObject.GetShowHideRows();
removeJson = null;
foreach (JSONObject jsonObject in rowJson)
{
if (jsonObject["FieldName"].GetString().EqualsIgnoreCase(removeField.FieldName))
{
removeJson = jsonObject;
}
}
if (removeJson != null)
{
rowJson.Remove(removeJson);
}
if (showHideGrid != null)
{
showHideGrid.SetShowHideFields(allFieldJson);
showHideGrid.SetShowHideRows(rowJson);
}
#endregion
#region 分组合计
var summarySet = this.View.GetControl<SummarySet>(CommonFilterConst.ControlKey_SummarySet);
var field = this.View.ParentFormView.BillBusinessInfo.GetField("FBillNo");
if (field == null)
{
return;
}
var summaryFiled = new SummaryField
{
Caption = field.Name,
Key = field.Key,
FieldName = field.Key,
EntityKey = field.EntityKey,
Field = field
};
var summaryObject = ((FilterModel)this.Model).SummaryObject;
if (!summaryObject.SummaryFieldList.Any(f => f.Key.EqualsIgnoreCase("FBillNo")))
{
summaryObject.AddSummaryFieldList(summaryFiled);
}
var allFieldJson = summaryObject.GetAllSummaryFields();
if (summarySet != null)
{
summarySet.SetSummaryFields(allFieldJson);
}
#endregion
}
}
}
二开方案.动态干预过滤界面中可选择的字段
【场景】干预过滤界面中过滤条件、高级过滤、排序、显示隐藏列界面中的可选择字段。【示例】在不修改过滤模型的情况下,以动态隐藏可选择的...
点击下载文档
本文2024-09-16 18:31:27发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-22694.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章