How to set grid to a class with an unknown set of columns?

0 Answers 75 Views
Grid
Deasun
Top achievements
Rank 3
Bronze
Bronze
Bronze
Deasun asked on 07 Nov 2023, 12:58 PM

Not sure if this is possible. Hopefully someone can point me in right direction.

I have a report with a set of columns in beginning and end. And within the center of the report is a set of columns that I wont know how many.

Example:

Col1, col2 , col3, col*, cola, colb, colc, etc....

Col* = 1 to many.

Each row is an order and the Col* represents items on the order.

I take it the telerik grid would have to be set to autogenerate the columns for the grid.

I am just not sure how I build the Class for the report result in this case.

 public class RtpOrderItems

{

public string? Col1 { get; set; }

public string? Col1 { get; set; }

public string? Col1 { get; set; }

public string? Col* { get; set; } // ? How would u go about this piece. Closest I came is the Dictionary field but I could get it to work.

public string? ColA { get; set; }

public string? ColB { get; set; }

public string? ColC { get; set; }

}

 

Thanks in advance

Dimo
Telerik team
commented on 09 Nov 2023, 12:14 PM

Using Dictionary is very similar to ExpandoObject Grid binding and you can see the linked KB article for inspiration how to configure the Grid.

You may also need to foreach Grid columns at runtime, which is also possible.

Deasun
Top achievements
Rank 3
Bronze
Bronze
Bronze
commented on 14 Nov 2023, 01:31 PM

Thanks.

Gives me something to look at. :)

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Deasun
Top achievements
Rank 3
Bronze
Bronze
Bronze
Share this question
or