Can Report (rdlc) Table or Matrix Column Width Be Set at Runtime?
2009-08-25 22:12
489 查看
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
相关文章推荐
- org.apache.hadoop.hbase.DoNotRetryIOException: Class org.apache.phoenix.coprocessor.MetaDataEndpointImpl cannot be loaded Set hbase.table.sanity.checks to false at conf or table descriptor if you want
- 为什么无法设置断点?提示信息:One Or More Breakpoints cannot be set and have been disabled.execution will stop at the beginning
- Debug error:"One or more breakpoints cannot be set and have been disabled.Execution will stop at the beginning of the program."
- One or more breakpoints cannot be set and have been disabled.Execution will stop at the beginning of the program
- Debug error:"One or more breakpoints cannot be set and have been disabled.Execution will stop at the
- One or more breakpoints cannot be set and have been disabled!Execution will stop at the beginning of the program
- One or more breakpoints cannot be set and have been disable.Execution will stop at the begining of the programe
- msyql同步的时候报错 : 错误代码: 1293 Incorrect table definition;there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- java.lang.RuntimeException: Date pattern must be set for column update_time in the schema of component
- Error: One of setGitDir or setWorkTree must be called.
- ubuntu 打开eclipse出现A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be ... 解决方法
- SP2-0678: Column or attribute type can not be displayed by SQL*Plus
- IAR调试时出现IAR one or more breakpoints could not be set and have been disabled的解决办法
- The table name must be enclosed in double quotation marks or sqare bracket while accessing EXCEL by
- Qt for Android - ANT_HOME is set incorrectly or ant could not be located
- [Err] 1075 - Incorrect table definition; there can be only one auto column and it must be defined as
- alter table t_agent_adv alter column status set default 1;
- fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.
- Oracle ORA-01747: invalid user.table.column, table.column, or column specification
- ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form