Incorrect usage of Parameters object

2 posts, 0 answers
  1. Frank
    Frank avatar
    1 posts
    Member since:
    Mar 2011

    Posted 20 Mar 2013 Link to this post


    I'm trying to use a custom function in my expression to decide what field should be displayed in the textbox, what grouping should be done, what formatting style should be applied, visibility and how the drilldown functions work.

    So far I got here (example of displaying text)
    public static string GroupDisplay(int GroupNumber, Telerik.Reporting.ReportParameterCollection parameters, decimal? RecordCenterKey, decimal? RecordUserKey, DateTime? BillDT_DateTime, decimal BillDT) {
                switch (GetGroupingForGroupNumber(GroupNumber)) {
                    case ReportGrouping.None:
                        return string.Empty;
                    case ReportGrouping.Centers:
                        return CenterName(GetCenterKeyFromParameters(parameters), RecordCenterKey, GetViewSubCentersFromParameters(parameters));
                    case ReportGrouping.Users:
                        return CreateUserName(RecordUserKey);
                    case ReportGrouping.Date:
                        return CheckDate(GroupDate(BillDT_DateTime, BillDT));
                        return string.Empty;

    My expression:
    = GroupDisplay(1, Parameters, Fields.TxTicket_CenterKey, Fields.TxTicket_UserKey_BilledByKey, NULL, Fields.TxTicket_BillDT)

    The reason why I am using the Telerik.Reporting.ReportParameterCollection instead of using every parameter separately is because there are 7 default parameters and many optional depending on the report, I want to use the same expression in all 40 so if something changes I can change the expressions in code for all of them in no time.

    Am I using a bad approach to solve this or is it something that is not possible in the current release of Telerik Reporting

    Kind regards,
  2. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 25 Aug 2015 in reply to Frank Link to this post


    2+ years later, same problem. Got around it using ​report's ​code ​behind file like this:


    Report.ItemDataBinding += (sender, e) =>
                    // get processing report instance
                    var report = (Telerik.Reporting.Processing.Report) sender;
                    // convert to simple dictionary
                    var ods = new ObjectDataSourceParameter("parameters"
                        , typeof(IDictionary<string, object>)
                        , report.Parameters.ToDictionary(rp => rp.Key, rp => rp.Value.Value));

                    // Transfer ReportParameter values to the repository
                    if (!​Repository.Parameters.Any())
                        Repository.Parameters[0] = ods;

    Object called Repository is my (Object)DataSource. It has a Method which takes an IDictionary<string,object>. This holds all ​report parameters with current values.

Back to Top