How create table with dynamic columns

2 posts, 0 answers
  1. Marcelo
    Marcelo avatar
    14 posts
    Member since:
    Jun 2011

    Posted 19 Nov 2013 Link to this post

    Hi all,

    I want design a report with a table,  but the number of columns is dynamic. How I can do it?  I receive data from a Stored Procedure.
    If you can, please send an example.

    Best Regarsd,
    Marcelo Videira
  2. Stef
    Stef avatar
    3611 posts

    Posted 20 Nov 2013 Link to this post

    Hi Marcelo,

    The best approach is to start by creating a sample Table item using the provided reporting designer and Table Wizard. Then get the code generated by the designer in the report's designer.cs(vb) file. This will help you get more familiar with the Table item structure and create code generating Table item based on provided data schema (number of columns and column names).

    As it is not recommended to modify the report definition once the processing has started, add the dynamically created Table item to the report instance Items collection, before displaying the report:
    var report = new MyReport();
    var myTable = GenerateTableItem();
    report.Items.Find("detail", true)[0].Items.Add(myTable);
    reportViewer1.ReportSource = new InstanceReportSource{ ReportDocument = report };

    I hope this information helps you.


    New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Back to Top