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

Dynamic grid

1 Answer 1621 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Meenakshi
Top achievements
Rank 1
Meenakshi asked on 06 Feb 2019, 05:34 AM

I want to create dynamic grid in ASP .Net MVC using Kendo grid. No of Columns are not fixed. It will get from database based on some conditions.

What will be the correct way to do it?

Also, If any of column has image url, in that case i want to display fixed size image 

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 07 Feb 2019, 02:46 PM
Hello Meenakshi,

A possible solution is to generate the columns dynamically. In the link below you will find an article which demonstrates how to bind the grid to a DataTable and generate the columns dynamically, also a sample is included:


Furthermore, within the column generation you could check whether the current column is the one containing the url and if it is crate a ClientTemplate which contains an image.

e.g.

foreach (System.Data.DataColumn column in Model.Columns)
        {
            var c = columns.Bound(column.ColumnName);
            if (column.ColumnName == "PictureUrl")
            {
                c.ClientTemplate("<img src='#=PictureUrl#' width='200px'/>");
            }
         ...
        }


Regards,
Georgi
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.
Tags
Grid
Asked by
Meenakshi
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or