Lists growing horizontally and vertically

1 Answer 350 Views
Report Designer (standalone)
Krasimir
Top achievements
Rank 3
Iron
Iron
Iron
Krasimir asked on 07 Nov 2023, 03:53 PM

Hi all,

I have the following case with Telerik Reporting. I have a list which is fed with some data. The number of items may vary from 0 to practically unlimited. I want to show up to 3 records on a line. New records should go on a new line in the report.  I used this article as a reference but I still cannot solve it elegantly as the number of elements may be different each time -> https://docs.telerik.com/reporting/knowledge-base/how-to-create-multi-column-report---across-the-page-and-then-down

I'm sending a sample report as a reference. Does anyone have ideas on how to handle this? Some of the problems I encounter are:

  • some times some of the values are not rendered
  • sometimes there are blank boxes
  • I want the number or rows to grow dynamically based on the number of elements I want to visualize in the list

Regards,
Krasi

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 10 Nov 2023, 10:18 AM

Hello Krasi,

Thank you for the attached files!

Indeed, the approach from the Creating Multi-Column Report - Across the Page and Then Down - Telerik Reporting KB article is one of two ways to go about it.

I have inspected the report and it at first visualized with 2 columns rather than 3. The reason for that was that the column grouping was using % 2 on the index field rather than % 3. After I changed that, the columns started displaying correctly:

There was also a problem with the CSV data:

id, name
0, str0
1, str1
2, str2
3, str3
4, str4
5, str5
7, str6

The last row skips a number and goes from 5 to 7 which would be the cause of blank boxes and/or values not being rendered. After I corrected the last id to be 6, the data was rendered as expected:

With that being said, it may be hard to keep the id field consistent with real data especially if there is filtering. If you are using SqlDataSource for your real data, you can use functions such as row_number() to dynamically generate a field to use for the column and row grouping:

row_number() OVER (ORDER BY [Row]) - 1 as RowIndex,

The other way of rendering multi-column reports is through the ColumnCount property. However, when using this approach, the data goes first down and then across. This means that if there is enough space, all data will fit in a single column instead of there always being three columns as with the other approach.

If you are interested to learn more about this approach, you may visit the Multi-Column Reports at a Glance - Telerik Reporting article.

I hope that the provided information will help. Please let me know if you need further assistance.

Regards,
Dimitar
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/.
Krasimir
Top achievements
Rank 3
Iron
Iron
Iron
commented on 10 Nov 2023, 04:32 PM

Thanks a lot, Dimitar,

I managed to optimize the groupings and your input helped a lot. By the way, it may be a good idea to consider some components that support listing elements in a list that can grow both vertically and horizontally. I've had the same case with few clients already. They were expecting to provide a list of elements ( from some source), limit the number or columns and let the list decide when to visualize elements on a new line without dealing with IDs, etc.

Once again, Thanks a lot for the support!
Krasi

almostEric
Top achievements
Rank 1
Iron
Iron
commented on 14 Apr 2025, 01:28 PM

Hi, I am trying to do the same thing, except that the list is within a group so the ID field will not work.
Also, I am using an object data source. 
I tried to group the list by the RowNumber() function but get an error that aggregate functions can't be used in grouping expressions.

Thoughts?
Dimitar
Telerik team
commented on 17 Apr 2025, 11:03 AM

Hi Eric,

Indeed, aggregate/data function such as RowNumber() cannot be used in the grouping expressions.

Do you use the ID field for the group that the list is inside of? I suppose the list is created for each instance of the group which will change for unique value of the ID field, is that correct?

This would explain while the approach is not working. If you are using the ID field for the list groups as well, the ID field won't change, it will be the same for each record of this group, thus the list column grouping won't create the additional columns.

The only way to achieve the desired behavior would be to add another field to your data. This field should start at 0 for each unique ID, for example:

RowIndex,Id,Value
0,1,value1
1,1,value2
0,2,value1
1,2.value2
2,2,value3

Notice how the "RowIndex" field restarts for each new ID. This will allow you to use the "RowIndex" field for the list groups and achieve the multi-column layout despite the ID being the same in the parent group.

I see that you are working with the ObjectDataSource component, however, I do not know from where the data is pulled. I assume that you may still be pulling the data from a database in the ObjectDataSource component. You can either modify the data in the code there so that the "RowIndex" field is included as suggested above, or you can try to do it from SQL, I will link relevant links for this task below:

I hope that the suggested approach will help. Let me know if you have any additional questions.

 

almostEric
Top achievements
Rank 1
Iron
Iron
commented on 21 Apr 2025, 01:03 PM

Hi,

So, there is no way for the report iteself to generate this RowIndex field? With this proposed solution, my application and data would need to be aware of how the report is grouping the data, which really reduces the flexability

Dimitar
Telerik team
commented on 24 Apr 2025, 07:04 AM

Hi Eric,

Yes, the report and the other data items do not modify the data, they use the data returned by the assigned data source component as is.

 

Tags
Report Designer (standalone)
Asked by
Krasimir
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Dimitar
Telerik team
Share this question
or