This is a migrated thread and some comments may be shown as answers.

How do I create a grid column that has multiple different data types

1 Answer 612 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 13 Jul 2017, 04:24 AM
I am porting a Silverlight website to HTML5 for my company and we are heavily using Telerik controls, as it's one of the only frameworks that has the richness we had while using Silverlight.  We have had great success as Telerik has had every widget and feature we had in our silver light, so it's been great being able to use a single framework for all of our grid and charting needs.

What I am stuck on right now is creating a grid that has a single column but supports different data types for each row.  For example the column might had a field for floats, a drop down menu, and a field for strings.  In Silverlight this was almost no effort to do.  You could take your class instance and drop it in a grid in XAML and XAML knew all of the data types and made each cell match the type(i.e. and editable string field for a string, a drop down menu for an enum, etc.).

What I am wondering is how to achieve this same functionality in Telerik.  Keep in mind that the data source is not an IEnumerable, it is a very large class instance with hundreds of different data members of differing types(int, float, bool, enum).  I attached a screenshot of what this looks like in silver light.  There are 2 columns in the screenshot, the left is a read-only text field, and the right-side column is where you change the values. 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 17 Jul 2017, 12:52 PM
Hello Aaron,

By default the Grid is intended to show only one type of data per column. Thus, having different data types is not available out of the box. Such functionality would require the data for the field to be stored as string. In turn this would mean that complex logic should be implemented for validating the data. 

With that said, I would recommend configuring ViewModel on the server where each different data type is stored in a separate field. This would result in considerably less code that is responsible for validating the user input. Also, you would be able to use a lot of the built-in validation features in MVC. 


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Aaron
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or