在 Telerik Reporting 中的 运行 时间添加表格

Adding tables at run time in Telerik Reporting

我一直在阅读 Telerik 的文档,我不确定这是否可行:我被要求在 运行 时间将 table 添加到报告中,但我没有这样做以编程方式。查询是 运行,它获取分层数据,报表所有者想为最顶层 parent 的每个成员向报表添加一个新的 table,以便每个最顶层 [=26] =] 有自己的 table,table 顶部的文本框标题包含 parent 的名称,格式如下:

TopParent1

[父母 1 的 table]

TopParent2

[父母 2 的 table]

...

有谁知道我如何在不以编程方式这样做的情况下做到这一点?我看到的每个示例 and/or 位文档都与以编程方式添加 tables.

有关



It is possible to add tables to a report at run time, without doing so programmatically?

R: 不可能添加 table 而不以编程方式说明:每个元素的大小、确切位置等。 .. ..


如何创建带有条件显示的 'hierachical' 报告?

1/。分层报表。

阅读 the telerik official tutorial 关于 如何:使用子报表项创建主从报表

使用SubReport report item you can display one report within another report. The data for each SubReport可以完全不同

但是您可以通过 Passing Parameters to a SubReport 实现 Parent/chield 关系。

/!\ Caution /!\
Page sections are not related to the report itself, but are relative to the paper or screen. Thus page sections of nested/detail reports are ignored and only the page sections of the main report are visible.

为了让部分在每个页面上重复类似于页面部分,请考虑使用未绑定组(未指定分组标准)并将其部分的 PrintOnEveryPage 属性 设置为 True。请注意,您不能在组部分中使用 PageCount 和 PageNumber 全局对象。

2/。条件显示

您将需要hide Report if subreport have no result

如果你想让用户选择他是否想要一些子报告。 您可以通过将参数从调用应用程序传递到报表构造函数来实现。 并使用诸如位域或枚举之类的东西来选择要显示的内容。

以及后面的主报告代码中的 C# 控制器呢?

public myReportConstructor(int SubreportToDisplay)
{
    InitializeComponent();
    Hiden_Display(SubreportToDisplay);
}

private void Hiden_Display(int _code)
{
    if ((_code & (int)myEnum.InfoClient) != (int)myEnum.InfoClient) 
        HideNShrink(SUBREPORT_CLIENT);
    if ((_code & (int)myEnum.Item) != (int)myEnum.Item) 
    { 
        HideNShrink(SUBREPORT_Product.Item1); 
        HideNShrink(SUBREPORT_Product.ItemTWO); 
    }
}

 private void HideNShrink(ReportItem target)
{// http://www.telerik.com/support/kb/reporting/details/collapse-the-container-when-hiding-child-report-items-
    target.Visible = false;
    target.Height = Telerik.Reporting.Drawing.Unit.Pixel(1); 
} 

我在设计器中使用了一个小技巧,每个子报表项都设置为 public:

 private Telerik.Reporting.TextBox textBox17;
 public Telerik.Reporting.SubReport SubReport_Client;
 public Sub_Client sub_CLI1;

隐藏客户端时我会使用SubReport_Client.
那就是 SubReport item,我的 SubReport Sub_Client 的容器;
(是的,他们给容器命名,containt 是同一个名字,这首先令人困惑,但这是 Vs/Telerik 选择)
隐藏其他子报表中的子报表时。
我用的是ContaintSubReport,Container的嵌套嵌套SubReport.
喜欢:sub_CLI1.nested-nested_SubReport

我能够回答我自己的问题如下:

  1. 创建两个空白报表。
  2. 在选择用于详细报告的报告上,删除报告 header 和页脚。
  3. 将数据源和 parameter/s 添加到详细报告(在我的例子中,一个 SQL 数据源)并将报告数据源设置为此处创建的数据源。
  4. 将组添加到报告,并将分组值设置为 top-most 结果查询绑定到报告。 (分组 = Fields.Parent)
  5. 创建文本框并将值设置为顶部结果的字段 (textbox1.Value = Fields.Parent) 或使用数据资源管理器将 Fields.Parent 拖放到组 header。
  6. 创建文本框以模仿 table 列标题(每个列标题一个文本框)并将它们放入组 header 中,文本框包含最上面的结果(或 Fields.Parent).
  7. 在报表的详细信息部分中为查询中的其余字段(Fields.Child1、Fields.Child2、Fields.Child3 等)拖动或创建文本字段,并与其列垂直对齐header.预览报告——它应该包含一个 table-like 结构,在每个顶部结果上重复。
  8. 切换到其他报告。
  9. 向该报告添加相同的 parameter/s。
  10. 将子报表项添加到该报表的详细信息部分。
  11. 将子报表报表源设置为类型和报表文档,然后select详细报表的名称(此处创建的第一个报表)。
  12. 将子报表的 parameter/s 设置为子报表中使用的相同 parameter/s。

使用它,我基本上可以在查询的第一列中为每个项目添加 table。首先创建的报表用作查询的包装器,并且因为它作为子报表项与我创建的分组一起放置在另一个报表中,所以它可以根据需要重复以显示所有行查询。

为此,我使用了 master-detail reports and report structures 的 Telerik 文档。