如何在运行时更改 SQL Server Report Services 报告的列顺序? [英] How can I change the column order of a SQL Server Report Services report at runtime?
问题描述
我想在运行时根据例如更改 *.rdlc
报告的标题/列的顺序用户偏好设置.我发现您可以使某些列不可见,但我还没有找到更改列顺序的方法.我在 ASP.NET 网页中使用 ReportViewer 控件.在这种情况下,在运行时意味着布局可以在两个页面请求期间更改.我在某处读到您可以动态配置 rdlc xml 或使用 rdl 对象模型动态创建报告定义作为请求处理的一部分.
I would like to change the sequence of the headers/columns of an *.rdlc
report at runtime based on e.g. user preference settings. I found that you can make some columns invisible, but I haven't found a way to change the order of the columns. I am using the ReportViewer control in an ASP.NET web page. And at runtime in this case would mean that the layout can change during two page requests. I read somewhere that you could configure the rdlc xml dynamically or use the rdl object model to create the report definition dynamically as part of the request handling.
以下示例有望更好地解释我正在尝试做的事情:
The following example should will hopefully explain better what I am trying to do:
表格或矩阵的默认报告列布局:
Default report column layout of a table or matrix:
Date Item Price
在运行时动态更改列的顺序:
Dynamically changed order of columns at runtime:
Item Price Date
推荐答案
我做过类似事情的唯一方法是通过参数.
The only way I've ever done something similar is through parameters.
Header cell expression: =Parameters!Column1.Label
Row cell expression: =Fields(Parameters!Column1.Value).Value
其中 label
参数是列标题,值是数据集中的字段名称.因此,在您的示例中,将有 3 个 Column 参数,所有参数都具有 Date
、Item
、Price
的可用标签/值,并且更改参数将确定列内容.
Where the label
parameter is the column header and the value is the Field name in your dataset. So in your example there would be 3 Column parameters, all with the available label/value of Date
, Item
, Price
and changing the parameters will determine the column contents.
这篇关于如何在运行时更改 SQL Server Report Services 报告的列顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!