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

Report API - how to set value

4 Answers 237 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Prashant
Top achievements
Rank 1
Prashant asked on 10 Apr 2019, 01:21 PM

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

4 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 15 Apr 2019, 07:27 AM
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
0
Marcel
Top achievements
Rank 1
answered on 23 Apr 2019, 12:10 PM

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

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

 

0
Todor
Telerik team
answered on 26 Apr 2019, 09:44 AM
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
0
Marcel
Top achievements
Rank 1
answered on 09 May 2019, 05:22 AM
Thx @Todor for your reply
Tags
General Discussions
Asked by
Prashant
Top achievements
Rank 1
Answers by
Todor
Telerik team
Marcel
Top achievements
Rank 1
Share this question
or