Checkbox set value based on record exsiting

1 Answer 39 Views
DataSource SQL Expressions Report Designer (standalone) SubReport
Jason
Top achievements
Rank 1
Jason asked on 29 Jul 2024, 01:33 PM

I have a program to Order a widget.  When they order widgets, they are allowed to pick and choose options for those widgets.

The options are stored as individual records in a SQL table like this:

ProductID      OptionID
     5                     6
     5                      13
     5                      101

So, I want my report to show the total list of options as checkboxes, when that value is present in the datasource.  Options not selected should be unselected checkboxes.

I'm guessing this will be a subreport, passing in my ProductID.  The result would be a datasource with three records.  How do i associate these records to trigger checkboxes on my report?

Thanks

I would like to avoid writing my SQL to include record fields for every possible value as the options will change and I'd have to re-write the SQL every time.

1 Answer, 1 is accepted

Sort by
0
Ivet
Telerik team
answered on 30 Jul 2024, 03:34 PM

Hi Jason,

I noticed that you have also opened a support ticket, however, to make the solution available to public, I will copy my answer here as well.

You need to make a "Report Parameter" for the available product IDs - Adding Report Parameters Explained - Telerik Reporting.

Then, create a parent row group on a list report item following the instructions from the Adding Groups to Table and Crosstab Items article. The grouping should be based on the ProductId field 

This will create a second column in which you have grouped data and in this panel, you can put as much as you want "Checkbox". You can take a look at the example picture below how it would look like:

To check for each CheckBox item if it should be checked, you need to use an expression such as = Item(0,(AllValues(Fields.Option))) = "Option1" where you first take all values then you use the "Item" function - Utility Functions at a Glance - Telerik Reporting, where the given index takes the value from the array.

This way, we can check for each checkbox whether it should be checked for the specific Option ID. Note that you may need to sort the data by the OptionID field to ensure that the order of the IDs is correct for the order in which we check them in the CheckBox items. I've made a sample report for you to have a look at and test.

I hope this information helps. I will be glad to assist you further.

Regards,
Ivet
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Tags
DataSource SQL Expressions Report Designer (standalone) SubReport
Asked by
Jason
Top achievements
Rank 1
Answers by
Ivet
Telerik team
Share this question
or