This is a migrated thread and some comments may be shown as answers.

Dynamic GroupHeaderSection In Telerik Report

4 Answers 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Negin
Top achievements
Rank 1
Negin asked on 28 Jan 2013, 12:58 PM
I have created a report in Silverlight. The report has a string parameter that its value is set in code behind of MainPage.xaml like this:(the MainPage.xaml contains a Silverlight ReportViewer)

public MainPage()
 {
     InitializeComponent();
     this.ReportViewer1.RenderBegin += new RenderBeginEventHandler(ReportViewer1_RenderBegin);
 }
 
 void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
 {
     args.ParameterValues.Add("reportParameter", "Header1;Header2;Header3");
 }

I want to split this parameter  by comma in MyReport.cs and add "Header1", "Header2" and "Header3" to GroupHeaderSection Items of the report.

First, I write below code in the constructor method of report:
string[] splitedReportParameter =  this.ReportParameters["reportParameter"].Value.ToString().Split(',');
for (int i = 0; i < splitedReportParameter.Length; i++)
{
    Telerik.Reporting.TextBox CaptionTextBox = new Telerik.Reporting.TextBox();
    labelsGroupHeader.Items.AddRange(new ReportItemBase[] { CaptionTextBox });
    CaptionTextBox.CanGrow = true;
    CaptionTextBox.Name = splitedReportParameter[i] + "CaptionTextBox";
    CaptionTextBox.StyleName = "Caption";
    CaptionTextBox.Value = splitedReportParameter[i];              
}
but, it didn't work and I think the reason is that the report parameter isn't set in the constructor. Moreover, I have a problem related to Location and Size of each TextBox.

Thanks,

Negin

4 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 31 Jan 2013, 05:05 PM
Hello Negin,

Could you, please, elaborate a little bit more on your scenario. How exactly you want to position the Textboxes and what is the final result which you want to achieve?

The actual parameter value is not available until the processing stage when it is too late to modify the report definition. The only possible approach is to use a data item (List/Crosstab), which will serve as a repeater for the Textbox item and its actual data source will depend on the selected parameter's value.

However, base on your final goal we may suggest you another approach.

Kind regards,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Negin
Top achievements
Rank 1
answered on 02 Feb 2013, 05:01 AM
Hi,

Actually, I want to create a dynamic report. Before generating report, the user can select the fields which he wants to see in the report. 
The number of fields that the stored procedure (used in the report) returns is high and I want the user can select some of them that he needs.
Moreover, I have some limitations in using Table, because if the number of the fields is more than the size of the table I will get the object reference error

Thanks a lot,
Negin
0
Stef
Telerik team
answered on 06 Feb 2013, 08:59 AM
Hello Negin,

If the report is generated dynamically before the processing begins, the report parameter will be with their default values, and not the set ones. While using table item, it can be bound to a list of strings, which will be the header texts. The table/list/crosstab item can be rotated, so the item grows horizontally, without adding columns. You can test the Rotate Layout option exposed at design time (right click on a table cell - Rotate Layout option) and check how table item definition changes in the designer.cs of the report, if you need to create it purely in code.

Let us know if you have further questions.

All the best,
Stef
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Negin
Top achievements
Rank 1
answered on 13 Feb 2013, 07:33 PM
Hi Stef,

I could solve my problem using Table!

Thank you,
Negin
Tags
General Discussions
Asked by
Negin
Top achievements
Rank 1
Answers by
Stef
Telerik team
Negin
Top achievements
Rank 1
Share this question
or