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

create columns at runtime

2 Answers 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy Hompesch
Top achievements
Rank 1
Randy Hompesch asked on 24 Sep 2019, 10:39 AM

I have a situation where I don't know the number of columns I need at design time.

I want to do something like:

DateTime dt = DateTime.Now.Date;
int dayCount = 30;
.Columns(columns =>
{
    for (int i = 0; i < dayCount ; i++)
    {
          columns.Bound(model.datedata).Title(dt.AddDays(i).ToString())… blah blah blah
    }
}

 

Can someone show me an example of how to do this. Nothing I've found on the web seems to fit this bill.

Thanks …. Ed

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 25 Sep 2019, 07:47 AM

Hi Ed,

 

You can achieve this requirement using the same approach as in the ...\Views\Grid\ComboInHeader.cshtml sample of the attached project.

 

Feel free to try it in your original project and let me know if it works for you, too.

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Randy Hompesch
Top achievements
Rank 1
answered on 25 Sep 2019, 07:06 PM
Got it. It was what I needed. THanks.
Tags
Grid
Asked by
Randy Hompesch
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Randy Hompesch
Top achievements
Rank 1
Share this question
or