Set first value from data source as default

3 posts, 0 answers
    ANDREY avatar
    10 posts
    Member since:
    Nov 2016

    Posted 08 Nov 2018 Link to this post

    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. Ivan Hristov
    Ivan Hristov avatar
    232 posts

    Posted 13 Nov 2018 Link to this post

    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.

    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
    ANDREY avatar
    10 posts
    Member since:
    Nov 2016

    Posted 13 Nov 2018 in reply to Ivan Hristov Link to this post

    Ivan, thank you for answer. It is what I looked for!
Back to Top