0

我正在尝试动态生成 Telerik 报告表。实际上,除了上网之外,经过大量努力,我得到了以下代码,它工作正常,但没有呈现所需的输出。这是代码:

private void table1_ItemDataBinding(object sender, EventArgs e)
    {
        // Get data and bind it to the table
        var processingTable = (sender as Telerik.Reporting.Processing.Table);
        var data = GenerateTable(DomainClass.GetCurrentAsset());
        if (processingTable != null) processingTable.DataSource = data;

        // Better clear table before binding
        table1.ColumnGroups.Clear();
        table1.Body.Columns.Clear();
        table1.Body.Rows.Clear();

        HtmlTextBox txtGroup;
        HtmlTextBox txtTable;
        //int rowIndex = 0;

        for (int i = 0; i <= data.Columns.Count - 1; i++)
        {
            var tableGroupColumn = new TableGroup();
            table1.ColumnGroups.Add(item: tableGroupColumn);

            txtGroup = new HtmlTextBox
                           {
                               Size = new SizeU(Unit.Inch(2.1), Unit.Inch(0.3)),
                               Value = data.Columns[i].ColumnName,
                               Style =
                                   {
                                       BorderStyle = { Default = BorderType.Solid },
                                       BorderColor = { Default = Color.Black }
                                   },
                           };
            tableGroupColumn.ReportItem = txtGroup;

            txtTable = new HtmlTextBox()
                           {
                               Size = new SizeU(Unit.Inch(2.2), Unit.Inch(0.3)),
                               Value = "=Fields." + data.Columns[i].ColumnName,
                               //Value = data.Rows[rowIndex][i].ToString(),
                               Style =
                                   {
                                       BorderStyle = { Default = BorderType.Solid },
                                       BorderColor = { Default = Color.Black }
                                   }
                           };

            table1.Body.SetCellContent(0, columnIndex: i, item: txtTable);
            //rowIndex++;
            table1.Items.AddRange(items: new ReportItemBase[] { txtTable, txtGroup });
        }
    }

这是一张包含表格数据的 DataTable 的图片:

报告的数据表图像

最后,当然不是需要的当前输出:

报告结果(不需要)

所以问题是;Account_Price 列不显示价格,尽管是从数据存储中检索的,并且可以在上面的数据表图片中看到。

我已经逐行跟踪代码,并且可以在跟踪代码时找出价格。但我不知道为什么它们没有显示在浏览器中。

希望有人能帮帮我,非常感谢

4

1 回答 1

3

显然,这是后来 Telerik 报告的新问题。

我在这里的 Telerik 论坛中找到了答案: http ://www.telerik.com/community/forums/reporting/telerik-reporting/incorrect-dynamic-table-columns.aspx

基本上,您需要为 TableGroup 列分配一个唯一的名称:

TableGroup tableGroupColumn = new TableGroup();
//add this :
tableGroupColumn.Name = i.ToString();
于 2013-09-26T02:17:25.240 回答