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

parameterizing a predefined datasource

5 Answers 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gersh
Top achievements
Rank 2
Gersh asked on 29 Jun 2012, 03:59 PM
I'm passed an object as a datasource. It's a user-made(basically an array of hashtables)  I use this on subreports, and they populate fine. But the data repeats for numrows ^ #of nested subreports). How can I modify the datasource on subreports, to act like group programmatically?

needDataSource calls this:

        protected void shareData(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.ReportItemBase subreport = sender as Telerik.Reporting.Processing.ReportItemBase;                                   
            subreport.ItemDefinition.Report.DataSource = this.DataSource;             
        }

5 Answers, 1 is accepted

Sort by
0
Gersh
Top achievements
Rank 2
answered on 29 Jun 2012, 09:12 PM
I realized that was a dumb  question. What's happening is I have a template Report that holds a subReport object. Since there is no relation between the template and the report, The report repeats all the data according to how many rows i have in my dataset. Is this possible to keep thiisi template structure?
0
Gersh
Top achievements
Rank 2
answered on 02 Jul 2012, 09:21 PM
Ok, After much stress and annoyances, I realized that on NeedDataSoure event needs to populate the Parameters of each subreport that raises the event.

Help?
0
Peter
Telerik team
answered on 04 Jul 2012, 06:51 AM
Hello Gersh,

Generally the data items (subreport, table, list or crosstab) are a separate data region and does not make use of the report's data source. They have their own DataSource property which you have set in order to populate the item with data. However if you have in addition set the Report.DataSource property. The report engine will create a detail section with the data item for every row of your datasource. To avoid this behavior our suggestion is to set the Report.DataSource property to none or move the table item to another non repeating section such as report header or unbound group header (group without grouping). 

Up to you last question we are not sure that we have correctly understood your inquiry thus we will appreciate if you elaborate further on your scenario.

Regards,
Peter
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Gersh
Top achievements
Rank 2
answered on 12 Jul 2012, 04:45 PM
Hi Peter, thanks for  the reply.
http://tv.telerik.com/watch/reporting/video/telerik-trainer-reporting-subreports uses a ReportParameter with 2 parameters, a name and a type(9:10). When I try to make one programatically, it requires 3. What is the value assigned to?

public void populateSubReport(ReportPart details, string groupby)
        {           
            InstanceReportSource irs = new InstanceReportSource();
            irs.ReportDocument = details;
            report_body.ReportSource = irs;
            if (groupby != null) //problem part
            {
                 //PROBLEM
                details.ReportParameters.Add(new ReportParameter(groupby, ReportParameterType.Integer, "=Fields." + groupby));

                details.Filters.Add(new Filter("Fields." + groupby, FilterOperator.Equal, "=Parameters." + groupby));
                report_body.ReportSource.Parameters.Add(new Parameter(groupby, "=Fields." + groupby));
            }
            else //this works
            {
                foreach (Filter f in this.Report.Filters)
                {
                    details.Filters.Add(f);
                }                
            }            
        }
0
Peter
Telerik team
answered on 17 Jul 2012, 11:44 AM
Hello Gersh,

Generally the ReportParameter.Value property is used to specify the default value for the parameter and you can leave it blank. Additionally the Telerik.Reporting.ReportParameter class has a default constructor. Thus if you don't want to provide a default value you can use the default constructor, initialize only the properties you need and set the Parameter.Visible property to true. In this way the report viewer will have the appropriate UI representation for the report parameter and users will be able to select the appropriate value.

Kind regards,
Peter
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Gersh
Top achievements
Rank 2
Answers by
Gersh
Top achievements
Rank 2
Peter
Telerik team
Share this question
or