|
| 1 | +--- |
| 2 | +title: Rendering Layered Backgrounds in Telerik Reporting |
| 3 | +description: "Learn how to implement layered background rendering for date ranges inside crosstab/table/list cells." |
| 4 | +type: how-to |
| 5 | +page_title: How to Render Overlapping Date Ranges inside Crosstabs in Telerik Reporting |
| 6 | +meta_title: How to Render Overlapping Date Ranges inside Crosstabs in Telerik Reporting |
| 7 | +slug: rendering-layered-date-range-backgrounds-telerik-reporting-crosstab-cells |
| 8 | +tags: reporting, crosstab, textbox, panel, expressions, bindings, date-range, overlapping-backgrounds |
| 9 | +res_type: kb |
| 10 | +ticketid: 1703676 |
| 11 | +--- |
| 12 | + |
| 13 | +## Environment |
| 14 | + |
| 15 | +<table> |
| 16 | + <tbody> |
| 17 | + <tr> |
| 18 | + <td> Product </td> |
| 19 | + <td> Reporting </td> |
| 20 | + </tr> |
| 21 | + </tbody> |
| 22 | +</table> |
| 23 | + |
| 24 | +## Description |
| 25 | + |
| 26 | +I need to display overlapping date ranges inside a [Crosstab/Table/List]({%slug telerikreporting/designing-reports/report-structure/table-crosstab-list/overview%}) report item. Each row represents a unit, and each monthly cell should visually depict three date ranges with distinct background colors. |
| 27 | + |
| 28 | +The ranges overlap, and their rendering should follow a layered approach, with the outermost range appearing behind the inner ones. I need guidance on calculating pixel positions dynamically and rendering layered backgrounds within each cell. |
| 29 | + |
| 30 | +## Solution |
| 31 | + |
| 32 | +To achieve layered background rendering for overlapping date ranges: |
| 33 | + |
| 34 | +1. Use a [Crosstab]({%slug crosstab_item_get_started%}) item to represent the data in a tabular format. |
| 35 | +1. Place a [Panel]({%slug telerikreporting/designing-reports/report-structure/panel%}) inside the crosstab cells where you need to display the date ranges. The panel will occupy the entire cell and act as a *container* for other elements, such as **TextBox** items. This approach allows you to configure the textboxes as needed, since a single textbox alone would otherwise fill the entire cell. |
| 36 | +1. Add multiple [TextBox]({%slug telerikreporting/designing-reports/report-structure/textbox%}) items inside the panel to represent the date ranges. Each TextBox should correspond to a single date range color. |
| 37 | +1. Bind the [Location](/api/telerik.reporting.reportitem#Telerik_Reporting_ReportItem_Location) and [Width](/api/telerik.reporting.reportitem#Telerik_Reporting_ReportItem_Width) of each TextBox dynamically using [Bindings]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/using-expressions/bindings%}). This ensures the rectangles are rendered proportionally based on the date range extracted from the data. |
| 38 | + |
| 39 | +### Example |
| 40 | + |
| 41 | +Below is an example dataset and binding configuration: |
| 42 | + |
| 43 | +**Sample Data:** |
| 44 | + |
| 45 | +```csv |
| 46 | +text,date,month,sizex,position |
| 47 | +1,01/01/2025,1,0.5in,1.5in |
| 48 | +1,01/01/2025,2,0.3in,0in |
| 49 | +``` |
| 50 | + |
| 51 | +>note Ensure that the data includes the X and Y positions, and the sizes of the range bars. These values determine the length of the colored textbox that is being used to represent the range bar. |
| 52 | +
|
| 53 | + |
| 54 | + |
| 55 | +## Sample Report |
| 56 | + |
| 57 | +Download the [rendering-layered-date-range-backgrounds.trdp](https://github.com/telerik/reporting-samples/blob/master/Sample%20Reports/RenderingLayeredDateRangeBackgrounds/rendering-layered-date-range-backgrounds.trdp) report definition. |
| 58 | + |
| 59 | +## See Also |
| 60 | + |
| 61 | +* [Telerik Reporting Crosstab Overview]({%slug crosstab_item_get_started%}) |
| 62 | +* [Telerik Reporting Panel Overview]({%slug telerikreporting/designing-reports/report-structure/panel%}) |
| 63 | +* [Telerik Reporting TextBox Overview]({%slug telerikreporting/designing-reports/report-structure/textbox%}) |
| 64 | +* [Using Expressions in Telerik Reporting]({%slug telerikreporting/designing-reports/connecting-to-data/expressions/using-expressions/overview%}) |
| 65 | +* [How to Display Reports with Alternating Style Rows]({%slug how-to-display-alternating-style-rows%}) |
0 commit comments