首页 > 其他分享 >Can Report (rdlc) Table or Matrix Column Width Be Set at Runtime?

Can Report (rdlc) Table or Matrix Column Width Be Set at Runtime?

时间:2023-11-16 14:01:27浏览次数:43  
标签:tables Set Matrix Column column report table hidden columns

 

Using an rdlc report in ReportViewer, I need to create a table or matrix where the number of columns and the kinds of data displayed in the columns changes with each report.  For example, in one report, the second column may hold price information.  In another report, the second column may hold a product description.

Obviously, a column with descriptive text needs to be wider than a column with price info. So, the column widths can't be firmly set in the designer.  But, I can't figure out how to change the column width during runtime, in either the Table control or Matrix control.  (I prefer the matrix, but can use either.)

Setting the header or details textbox CanGrow property to true doesn't help for two reasons.  One is that (in a Table control) the textbox grows in width only to the first linebreak opportunity (a space between words).  The other is that we need to export the report to PDF and even if the CanGrow widens the column in the viewer, when exported to PDF the column returns to the design width.

Tried setting the Width property of the column to an expression, but it wouldn't let me.

Spent a week on this.  Is it possible?  If not, if I switched to a Crystal Report (don't want to, I'm Crystal-Report challenged), is there a way to make it work?

There is one very ugly workaround: the Hidden property of a table column can be set to an expression.  I could set up the table with two or three columns of different widths for each column in the final report.  Depending on the column header ('Price', 'Description', etc.), certain columns would be hidden based on how wide a column was needed.  For example, there could be two design columns (one narrow, one wide) for column two of the final report.  If the heading on column 2 is Description, make the narrow column hidden so only the wide column displays with the Description text.

Seems it would be better to set the column widths, if possible.

==============

I never found a pretty solution, so went with an ugly one.

The original ugly workaround I proposed worked great for viewing the report on-screen, but did not work when exporting to PDF.  By having three columns for every visible column in the final report, the table was 22 inches wide in design view, forcing the report to be 22 inches wide.  The export to PDF didn't like that, creating lots of extra blank pages.

The ugly solution that worked was creating multiple tables to acccount for all varieties of column widths and number of columns The tables are stacked on top of one another.  The "Hidden" property in each table is set to an expression that checks a report parameter to determine if that table is hidden or visible [=IIF(Parameters!paramTableId.Value = 33, False, True)].  The parameter value is passed in from the codebehind on the aspx page that holds the ReportViewer. 

Currently there at 23 tables in the stack.  All of the tables are centered horizontally.  When I had just 5 or 6 tables, the non-hidden table would appear on the screen centered in the report.  With 23 tables, the non-hidden table is left justified.  But, in both scenarios, the table is centered in the PDF version, which is all I care about.

================

http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/1f103afb-90c5-441a-93ba-7e2beeda0071/

http://forums.asp.net/t/967472.aspx



标签:tables,Set,Matrix,Column,column,report,table,hidden,columns
From: https://blog.51cto.com/emanlee/8419032

相关文章

  • CTFshow Reverse 36D杯 BBBigEqSet wp
    用ida打开程序,一点点看汇编,发现似乎是机器生成的,先是输入0x80长的flag,然后有0x80段运算,运算的内容是每一个字符乘一个系数相加后与一个数比较。查看代码.text:0000000000001175pushrbp.text:0000000000001176movrbp,rsp.text:00......
  • Kubernetes statefulset
    k8s的statefulset是用用于有状态服务的部署,存储和网络都是有顺序的,会按照顺序先down掉服务再起来,所以当部署的这台服务器down掉之后,就不能down掉这个服务,而会一直处于Terminating状态,无法启动新的服务。所以单副本的应用最好用deploy进行部署,使用statefulset可能会出现这种问题。......
  • setTimeout可以将字符串当成代码执行,类比eval函数。当遇到setTimeout或者SetInterval,
    请问以下JS代码的输出顺序是?letdate=newDate()setTimeout(()=>{console.log('1')},2000)setTimeout('console.log(2)',1000);setTimeout(function(){console.log('3')},1500);while((newDate()-date)<3000){}A报错B......
  • setTimeout 是浏览器环境提供的,JS 标准没有规定。不是JavaScript的全局函数,是浏览器(宿
    下列哪些函数是JavaScript的全局函数?AencodeURIBparseFloatCsetTimeoutDeval正确答案:ABD答案:A、B、D个人记忆方法:6(编码相关)+2(数据处理)+4(数字相关)+1(特殊)编码相关:escape()、unescape()、encodeURI()、decodeURI()、encodeURIComponent()、decodeURIComponent......
  • 因为offset和scroll其实都是“相对”来计算的。有其他元素做参照物,所以会回流一次,确保
    以下哪些操作会触发Reflow:varobj=document.getElementById(“test”);Aalert(obj.className)Balert(obj.offsetHeight)Cobj.style.height=“100px”Dobj.style.color=“red”正确答案:BC正确答案:BC。B计算了offsetHeight,C重新设置了高度。A打印出类名,无影响......
  • CF486D Valid Sets
    题目描述:给定\(n\)个点的树,点有点权,求满足最大点权与最小点权之差小于等于\(d\)的连通子图数目。答案对\(10^9+7\)取模。数据范围:\(1\led\le2000,1\len\le2000\)\(1\lea_i\le2000\)\(1\leu,v\len\)思路:根据我们以往的做题经验,因为要求选出的是一个连通子图......
  • Pset_AnnotationLineOfSight
    Pset_AnnotationLineOfSightPSET_TYPEDRIVENOVERRIDE / IfcAnnotation / LineOfSight注释视线:指定两个图元之间连接点处的视线特性。通常用于定义两条道路(尤其是通道和公共道路之间)交界处的视线可见性。: Définitiondel'IAI:spécifielespropriétésdu......
  • TreeSet
      ......
  • Spring5学习随笔-Set注入详解和构造注入
    学习视频:【孙哥说Spring5:从设计模式到基本应用到应用级底层分析,一次深入浅出的Spring全探索。学不会Spring?只因你未遇见孙哥】第四章、注入(Injection)1.什么是注入通过Spring工厂及配置文件,为所创建对象的成员变量赋值1.1为什么需要注入“通过编码的方式,为成员遍历进行赋值,......
  • jmeter-set up先登录获取token,再测试
    1.顶部加通用的信息头管理,cookie管理器 2.添加setup线程组,用户数为13.添加登录请求4.添加断言,添加debug调试 5.提取json,  6.添加debug,运行后查看是否获取到token 7.设置token为全局变量 8.再添加线程组,线程组可正常设置并发数需要用到token的地方再添加......