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

Set first value from data source as default

2 Answers 869 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ANDREY
Top achievements
Rank 1
ANDREY asked on 08 Nov 2018, 10:01 AM

Hello, I have report parameter and I dynamically change the data source in available values, then I'd like to pick the first value (it could be various) as default. How can I implement this since the attribute ReportParameters["proc"].Value just accept an object?

Is the only option to query the data manually from code and then send first item?

Thank you for your attention!

2 Answers, 1 is accepted

Sort by
1
Ivan Hristov
Telerik team
answered on 13 Nov 2018, 08:06 AM
Hi Andrey,

The first value of the available report parameters can be obtained without writing any code, just using only build-in functions. We have the utility function Item(index, collection), which returns an item from a collection by its zero-based index. When the report processing starts, the engine will create an instance of Processing.ReportParameter class and populate its AvailableValues collection based on the parameter definition. This AvailableValues collection is basically a List of ParameterValue - a simple object that consists of Name and Value properties. In this case we can use the Item function to obtain the value of the first item in the AvailableValues collection like this:
= Item(0, Parameters.Parameter1.AvailableValues).Value
where Parameter1 is the name of the report parameter - "proc" in the current scenario.

With this expression set in the ReportParameter's Value field, when the report is previewed, the first report parameter value will be selected by default.

Regards,
Ivan Hristov
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
ANDREY
Top achievements
Rank 1
answered on 13 Nov 2018, 09:18 AM
Ivan, thank you for answer. It is what I looked for!
Tags
General Discussions
Asked by
ANDREY
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
ANDREY
Top achievements
Rank 1
Share this question
or