Report API - how to set value

5 posts, 0 answers
  1. Prashant
    Prashant avatar
    3 posts
    Member since:
    Jan 2017

    Posted 10 Apr Link to this post

    Hi,

    I have crated class library report (.cs) and wanted to know how to set some value to textbox using ReportsController (i.e. web api)

     

    Thank you!

    Prashant

  2. Todor
    Admin
    Todor avatar
    270 posts

    Posted 15 Apr Link to this post

    Hi Prashant,

    Generally, we recommend to set values to report items (e.g. TextBoxes) in the report definition. You may use Expressions for this purpose. The data may come from a DataSource - check the available Data Source components. The value would be automatically calculated and resolved run-time by the Reporting engine.
    You may also use Report Parameters in the expression.

    If the value of a TextBox is supposed to come directly from the client (e.g. Report Viewer), you may set the value of the TextBox to the value of a Report Parameter (e.g. '= Parameters.ParameterName.Value') and pass the actual value from the user in the client ReportSource Parameters collection.

    You may also pass objects from the client to the report via the UserIdentity.Context property. This dictionary has been introduced as means for passing values from the HttpContext to the report. Details and example on how to use it can be found in How to use information from HttpContext in Custom Report Resolver KB article.

    If the above approaches are not suitable, you may use Custom Report Resolver where to instantiate the report, set/modify the value of the report item and return the modified report instance wrapped in an InstanceReportSource.

    Regards,
    Todor
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Marcel
    Marcel avatar
    21 posts
    Member since:
    Jun 2008

    Posted 23 Apr in reply to Todor Link to this post

    How to access the UserIdentity.Context in the report for example in an expression?

    UserIdentity.Context["SomeKey"] doesn't work.

     

  4. Todor
    Admin
    Todor avatar
    270 posts

    Posted 26 Apr Link to this post

    Hello Marcel,

    You may pass the UserIdentity.Context and the Key to a custom user function that would return the Value of the Key, e.g. like :

    = Namespace.GetFromContext(UserIdentity.Context, key)

    The user function may generally look like :

    public static object GetFromContext(Dictionary<string, object> context, string key)
    {
        object value = context[key];
     
        return value;
    }


    The report designers do not support the type Dictionary, so it is not possible to use an Expression like '=UserIdentity.Context["SomeKey"]' directly in the report definition.

    Regards,
    Todor
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Marcel
    Marcel avatar
    21 posts
    Member since:
    Jun 2008

    Posted 09 May in reply to Todor Link to this post

    Thx @Todor for your reply
Back to Top