This is a migrated thread and some comments may be shown as answers.
Providing default values to Dynamic Columns
1 Answer 6 Views
This is a migrated thread and some comments may be shown as answers.
Mudit
Top achievements
Rank 1
Veteran
Mudit asked on 08 Jun 2020, 02:11 PM

     Hi

 

We are trying to create a grid which will have columns added dynamically. Once the grid is bound properly it complaints about not having a default value to the dynamic columns. How can we provide a dynamic columns with default values.

 

Also we did initialize these values in model constructor, logically those should have been picked up but somehow grid wants explicit default values for all columns.

 

Regards

M.

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 10 Jun 2020, 01:02 PM

Hi Mudit,

 

I would suggest you take a look at the following sample project where dynamic Grid is created.

- https://github.com/telerik/ui-for-aspnet-mvc-examples/blob/master/grid/binding-to-datatable/KendoUIMVC5/Views/Home/Index.cshtml

When the Grid is created dynamically, you could return the Model to the view and iterate through its properties and their type. This way you could configure the DataSource Model and set the type of the fields. Also, if needed, you could set DefaultValue, by using the DefaultValue method

I hope the provided sample project will help. In case the issue continues to persist may I ask you to prepare a small isolated sample where the issue can be observed and send it back to us? This will help us to troubleshoot locally and provide you with further assistance. 

In case you have additional questions do not hesitate to contact us.

 

Regards,
Neli
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Mudit
Top achievements
Rank 1
Veteran
Answers by
Neli
Telerik team
Share this question
or