Setting styles from datasource

1 Answer 144 Views
Styling TextBox
Tom
Top achievements
Rank 1
Tom asked on 29 Dec 2022, 04:38 PM

Hello,

I'm evaluating Telerik as a possible reporting solution.  I'm totally new to Telerik and I currently use SQL Server SSRS for all reporting.  There are some things that SSRS does easily but I don't see a parallel in Telerik, at least not yet. 

Example: I have data that I retrieve from an SQL Server DB based on the client which contains style information for my reports.  I can retrieve a path for the client's logo, their preferred color patterns for headers, footers, table styles, backgrounds, fonts, font styles (bold, italic, etc.) and then in SSRS I can define these settings as expressions taken from the datasource.   Each client can have their own specific formatting so I want the report to be standardized in form but customized to the client with styles.

As a simple example, suppose I retrieve data that tell me the client wants Arial size 14 font for the title with gray background and Blue font color.  These are stored as separate values that I retrieve from a stored procedure and the datasource is bound to the report.  I created a mock report with the title, subtitle and rundate textboxes placed where they should be in the header section.  

How can I assign the font styles and coloring to the text boxes?

1 Answer, 1 is accepted

Sort by
0
Momchil
Telerik team
answered on 03 Jan 2023, 10:00 AM

Hi Tom,

You can assign the styles retrieved from your DataSource to their respective items through the use of Bindings.

Additionally, for further personalization, you can add several Report Parameters to the report, and set the DataSource of their AvailableValues property to the data source that you use to retrieve your style configuration. The attached GIF recording shows a sample of what you can achieve with Report Parameters.

I am attaching a demo report, as an implementation reference.

Regards,
Momchil
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tom
Top achievements
Rank 1
commented on 25 Jan 2023, 10:00 PM

Thank you, Momchil, for your reply.  I see how you can bind to parameters as your example showed.  Is it possible to have 2 datasets (sql server stored procedures) in a single report, and make a specific reference to one or the other? 

For example:

Dataset1 is called "Products" and has a product name, cost and quantity as data fields.

Dataset2 is called "Styles" and has fields containing the font color, font style, background color.

In my report I have a header with a textbox for the title.  I want to bind the textbox Value to the Product name in the Products dataset.  In fact, I was able to do that.   But I could not bind the textbox Background Color to the  color retrieved in "Styles"  because this dataset was not in the list of available bindings.  Is there I way I can reference the binding to use Styles.BackgroundColor? 

Momchil
Telerik team
commented on 30 Jan 2023, 01:28 PM

Hello Tom,

By design, report data items are meant to have only one data source, which is why the behavior you experienced is expected.

The recommended approach to achieve what you described, is to use the "Products" data source to retrieve your data and bind the styles using report parameters that get their available values from the "Styles" data source (as shown in the demo from my previous reply).

The issue with the method that you described is determining which record of the "Styles" data source to use. For example, if you add a binding to the TextBox and set its background color to "Styles.BackgroundColor", how will the report know which color to use if your "Styles" data source contains records with blue, green, yellow, etc?

 

That being said, if your "Styles" data source is flat (contains only one record), you can achieve what you described by always using the first record. To do that, you can use the "Styles" data source as a data source for your report and use the ReportItem.DataObject property to access the styles. For example:

Keep in mind that you will need to use a nested data item with a separate data source in order to retrieve any data.

I am attaching a modified version of my demo that illustrates the above, for your convenience.

I would not recommend this approach unless it is a strict requirement!

Tags
Styling TextBox
Asked by
Tom
Top achievements
Rank 1
Answers by
Momchil
Telerik team
Share this question
or