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

Report params null

4 Answers 482 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Licenses
Top achievements
Rank 1
Licenses asked on 07 Mar 2013, 03:46 PM
Hey,

We have updated our controls to Q1 2013. Since this update all the paramater values are null in code behind.  
Our report has a chart and a table.
The table is bound to a Objectdatasource. The function behind this ObjectDatasource gets al the params correct.
The chartseries are set from the code in the function OnNeedDataSource here the parameters (ReportParameters["SelectedBeginMonth"].value) aren't set since the new update.

Below the code we use.

The client code from silverlight
.........
reportViewer.Parameters[
"SelectedBeginMonth"] = selectedBeginMonth;
 reportViewer.Parameters["SelectedDuration"] = selectedDuration;
 
if (string.IsNullOrEmpty(reportViewer.Report))
            {
                //first time => setting the report will automatically load it
                reportViewer.Report = "Anton.Server.Reports.M01_OrganisationModule.KeyFigures.KeyFigures, Anton.Server.Reports, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            }
            else
            {
                reportViewer.RefreshReport();
            }

The code behind of the report 
(the params aren't correct)
protected override void OnNeedDataSource(object sender, EventArgs e)
        {
            base.OnNeedDataSource(sender, e);
 
            SetColumnWidth();
            SetColumnWidthRemarks();
 
            DateTime selectedBeginMonth = new DateTime(DateTime.Today.Year,DateTime.Today.Month,1);
            if (ReportParameters["SelectedBeginMonth"].Value != null)
            {
                DateTime.TryParse(ReportParameters["SelectedBeginMonth"].Value.ToString(), out selectedBeginMonth);
            }          
 
            int selectedDuration = 0;
            if (ReportParameters["SelectedDuration"].Value != null)
            {
                int.TryParse(ReportParameters["SelectedDuration"].Value.ToString(), out selectedDuration);
            }          
 
            keyFiguresChart.Series.Clear();
            for (int i = 0; i < selectedDuration; i++)
            {
                var serie = new ChartSeries
                {
                    DataYColumn = "Year" + (i + 1),
                    Name = selectedBeginMonth.AddYears(i).ToString("dd/MM/yyyy") + " - " + selectedBeginMonth.AddYears(i + 1).AddDays(-1).ToString("dd/MM/yyyy"),
                };
 
                serie.Appearance.ShowLabels = false;
                keyFiguresChart.Series.Add(serie);               
            }           
        }

The method that is bound to the objectdatasource of the table(the params are correct)
public IQueryable<KeyFiguresDto> GetKeyFiguresDtoForOtherData(bool showNewEmployees, bool showPercentageFemales,bool showPercentageMales,bool showPercentageUnknownGender, bool showPercentageInflow, bool showPercentageOutflow,
                                                            bool showPercentageParttimeEmployees, bool showPercentageXYearsSeniority, bool showPercentageYoungEmployees,
                                                            int keyFigureReportAge, int keyFigureReportSeniority, DateTime selectedBeginMonth, int selectedDuration)
        {
             
            selectedBeginMonth = selectedBeginMonth.AddYears(-selectedDuration).AddMonths(1);
            var endMonth = selectedBeginMonth.AddYears(selectedDuration).AddDays(-1);
 
            List<KeyFiguresDto> result = new List<KeyFiguresDto>();
            List<KeyFiguresEmployeesDto> employeeAtServiceForPeriod = new List<KeyFiguresEmployeesDto>();
 
........
Sodi We

4 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 12 Mar 2013, 08:12 AM
Hi Sodi We,

In report events our suggestion is to utilize the processing items as elaborated in Using Report Parameters programmatically help article. Check out the updated code snippet:

protected override void OnNeedDataSource(object sender, EventArgs e)
{
    base.OnNeedDataSource(sender, e);
 
    SetColumnWidth();
    SetColumnWidthRemarks();
 
    DateTime selectedBeginMonth = new DateTime(DateTime.Today.Year,DateTime.Today.Month,1);
    var processingItem = (Telerik.Reporting.Processing.Chart)sender;
    if (processingItem.Report.Parameters["SelectedBeginMonth"].Value != null)

Greetings,
Peter
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

0
Licenses
Top achievements
Rank 1
answered on 12 Mar 2013, 10:39 AM
Ok, this was the solution.

After solving this issue we noticed that we have another issue that came from the update, the method "SetColumnWidth" isn't working anymore. 

For setting the width we use the following code:

int nrOfColumns = 0;
.... txtXAxisName.Width = new Unit(21.6 / nrOfColumns, UnitType.Cm);

Maybe you changed something in the reporting whereby our code is executed to early or to late ? 

See attachment for the table with the txtXAxisName control in. 

Sodi We
0
Peter
Telerik team
answered on 14 Mar 2013, 11:32 AM
Hello Sodi We,

Generally our suggestion is to avoid changing the report definition in the processing stages and instead to update the report definition in the report constructor. Still if this is not applicable the only available option is to use ItemDataBinding event.

Regards,
Peter
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

0
Licenses
Top achievements
Rank 1
answered on 14 Mar 2013, 02:37 PM
Ok thanks
Tags
General Discussions
Asked by
Licenses
Top achievements
Rank 1
Answers by
Peter
Telerik team
Licenses
Top achievements
Rank 1
Share this question
or