二开案例.列表插件.列表查询隐藏指定分录下的所有列

【应用场景】
列表查询隐藏指定分录下的所有列。
【案例演示】
采购订单列表,过滤方案设置了列表显示单据头和单据体的字段,通过列表插件,控制列表最终仅显示单据头的字段。

【实现步骤】
<1>编写列表插件,代码如下。
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.List.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.QueryElement;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// <summary>
/// 【列表插件】列表查询隐藏指定分录下的所有列
/// </summary>
[Description("【列表插件】列表查询隐藏指定分录下的所有列"), HotUpdate]
public class HideEntryListPlugIn : AbstractListPlugIn
{
public override void PrepareFilterParameter(FilterArgs e)
{
base.PrepareFilterParameter(e);
var showEntityKeys = new[] { "FBILLHEAD" }; // 可显示的分录的Key
// 移除不显示的分录
this.ListModel.FilterParameter.SelectedEntities.RemoveAll(o => !showEntityKeys.Contains(o.Key, StringComparer.OrdinalIgnoreCase));
// 移除不显示的分录下的所有字段
this.ListModel.FilterParameter.ColumnInfo.RemoveAll(o => !showEntityKeys.Contains(o.EntityKey, StringComparer.OrdinalIgnoreCase));
// TODO
var filterString = e.FilterString;
// TODO 过滤条件不能有要隐藏的分录的字段,否则可能会因为主表关联分录表而产生重复数据行
var sortString = e.SortString;
// TODO 排序字段不能有要隐藏的分录的字段,否则可能会因为主表关联分录表而产生重复数据行
e.SortString = ResetSortString(this.ListModel.QueryInfo, showEntityKeys, sortString);
}
/// <summary>
/// 移除排序字段中不允许显示的字段
/// </summary>
/// <param name="queryInfo"></param>
/// <param name="showEntityKeys"></param>
/// <param name="sortString"></param>
/// <returns></returns>
private string ResetSortString(QueryInfo queryInfo, string[] showEntityKeys, string sortString)
{
if (string.IsNullOrWhiteSpace(so
二开案例.列表插件.列表查询隐藏指定分录下的所有列
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



