#报表#简单账表 代码创建的动态列,如何设置列宽

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

#报表#简单账表 代码创建的动态列,如何设置列宽

# 场景 在报表服务插件的GetReportHeaders方法里创建的列,设置列宽无效 ![image.webp](/download/0100d390c36983924db89a735087525a8845.webp) # 原因 报表的过滤框的显示隐藏列的字段有默认宽度,这个优先级较高 ![image.webp](/download/010021df7e92dcee45cdacb53f4c6c9ab410.webp) # 解决方法 编写过滤框的表单插件,修改显示隐藏列字段的默认宽度 ```language 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.Util; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; namespace HNKD.WZQ.Test.Plugin { [Kingdee.BOS.Util.HotUpdate] [Description("【表单插件】合同列表过滤框,动态显示隐藏列")] public class HTLB_FilterEdit : AbstractCommonFilterPlugIn { public override void AfterBindData(EventArgs e) { base.AfterBindData(e); //获取隐藏列字段 ICommonFilterModelService filterModel = this.Model as ICommonFilterModelService; if (filterModel == null) return; var fieldList = filterModel.ColumnObject.AllFieldList; //遍历字段设置列宽 foreach (var item in fieldList) { //标题包含 '日期' if (item.Caption.ToString().Contains("日期")) { //默认列宽 item.DefaultColWidth = 160; } if (item.Caption.ToString().Contains("人") || item.Caption.ToString().Contains("员")) { item.DefaultColWidth = 70; } if (item.Caption == "对方单位") { item.DefaultColWidth = 250; } //字段标识 if (item.Key == "FHTLX") { item.DefaultColWidth = 150; } if (item.Caption == "产品类型") { item.DefaultColWidth = 70; } if (item.Caption == "合同编码") { item.IsHyperlink = true; } } } } } ``` # 效果 ![image.webp](/download/01001da389ad9bcc48329e13ebd6c1091c11.webp) ![image.webp](/download/0100e9718959978f46ee8b7902c9ed9a267e.webp)

#报表#简单账表 代码创建的动态列,如何设置列宽

# 场景在报表服务插件的GetReportHeaders方法里创建的列,设置列宽无效![image.webp](/download/0100d390c36983924db89a735087525a8845.we...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息