Report params null

5 posts, 1 answers
  1. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 07 Mar 2013 Link to this post

    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
  2. Answer
    Peter
    Admin
    Peter avatar
    1611 posts

    Posted 12 Mar 2013 Link to this post

    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.

  3. DevCraft banner
  4. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 12 Mar 2013 Link to this post

    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
  5. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 14 Mar 2013 Link to this post

    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.

  6. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 14 Mar 2013 Link to this post

    Ok thanks
Back to Top
DevCraft banner