multiple values in a cell

1 Answer 60 Views
Grid
n/a
Top achievements
Rank 1
Iron
Iron
Iron
n/a asked on 07 Mar 2022, 04:39 PM

Hello,

I have a model to serve as data in a grid. Besides regular single field data, like strings and numbers etc, the model also contains a List of multiple subitems which need to be added to each row, in a cell. My grid would look like this:

FirstFieldName              SecondFieldName                 ListOfItemsField

------------------------------------------------------------------------------------------------

DataForItemOne          DataForItemOne                     SubItemOneOfItemOne

                                                                                         SubItemTwoOfItemOne

                                                                                         SubItemThreeOfItemOne

------------------------------------------------------------------------------------------------

DataForItemTwo          DataForItemTwo                     SubItemOneOfItemTwo

                                                                                         SubItemTwoOfItemTwo

                                                                                         SubItemThreeOfItemTwo

-----------------------------------------------------------------------------------------------

                              etc etc etc etc.

 

My question is: how am I able to add multiple values into a cell? As mentioned, the values belong to a List contained by the model. Each model in the table would have its own List of subitems.

Thank you very much.

Kind regards

1 Answer, 1 is accepted

Sort by
0
Nadezhda Tacheva
Telerik team
answered on 08 Mar 2022, 12:38 PM

Hi Astig,

You can use Column Template for the ListOfItemsField. Through its context you can get the field holding the subitems collection, loop through it and render the subitems in the desired way.

Here is a runnable example demonstrating this approach - https://blazorrepl.telerik.com/GGuHEClc31GigOy707. I am simply creating an <ul> with the available addresses for every Grid record.

You can use that as a base to setup the Grid in your application. Please let us know if any further assistance is needed in the meantime.

Apart from this approach, there is also another option for displaying hierarchical data in the Grid. Its Detail Template allows you to render a child Grid for the subitems. You may check it and see if it could be a better fit for your use case.

Regards,
Nadezhda Tacheva
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

n/a
Top achievements
Rank 1
Iron
Iron
Iron
commented on 08 Mar 2022, 12:49 PM

Got it! Thank you very much Nadezhda, that's very helpful
Tags
Grid
Asked by
n/a
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadezhda Tacheva
Telerik team
Share this question
or