Bind Grid to a list of primitive types

0 Answers 107 Views
Top achievements
Rank 1
Thibault asked on 08 Dec 2022, 09:17 AM


I would like to know if it is possible to Bind a Grid to a property of an object which is a list of primitive type (i.e. a List<string>).

My ViewModel is something like that:

public class ExampleViewModel
   public SomeType { get; set; }
   public SomeOtherType { get; set; }
   public List<string> SomeValues { get; set; }

And I imagined I could build the grid like that:

   .Columns(columns => columns.Bound(x => x))

As you understand, it would be a very simple grid consisting of only one column, with each row displaying one of the string values.
Is it possible, or can grid only work with objects and not with primitive types?

If I do that, it is to keep the Kendo's grid visual style, instead of manually writing and styling a table.

Thanks for your help.

Anton Mironov
Telerik team
commented on 13 Dec 2022, 07:09 AM

Hi Thibault,

Thank you for the code snippets and details provided.

In order to achieve the desired behavior, I would recommend creating a Model with one property - the list o the strings.

Use the pointed Model for the Grid and set one column that will use the property of the Model which stands for the list of the strings.

I hope this information helps. Let me know if further assistance is needed.

Kind Regards,
Anton Mironov

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question