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

Dynamic creation of columns in kendo editable grid

1 Answer 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leya
Top achievements
Rank 1
Leya asked on 23 Feb 2015, 07:24 AM
I have a model with ID and and array of values, I need each of the array value to be displayed in separate column in kendo grid and all this should be editable fields.

public int Id { get; set; }
public double[] List { get; set; }

I have tried the following way however it display all values in one cell.


@model IEnumerable<HoursModel>

<div id="PlanningGrid">
    @(Html.Kendo().Grid(Model)
          .Name("Grid")
          .Columns(columns =>
          {
             //// columns.AutoGenerate(true);
              
              columns.Bound(c => c.Id).HeaderHtmlAttributes(new {@class = "grid-header-cell"}).HtmlAttributes(new {@class = "grid-row-cell planningoverview-grid-cell1"});

              columns.Bound(p => p.List).ClientTemplate("#=generateTemplate(HoursList)#");
              //// columns.Bound(m => m.EmployeeId).ClientTemplate("# for (var i=0;i<4;increment(i)) { console.log(i) } #");
              
          })
          .Sortable())
    
</div>

<script type="text/javascript">
    function generateTemplate(Wetness) {
        var template = "<ul>";
        for (var i = 0; i < Wetness.length; i++) {
            template = template + "<li>" + Wetness[i] + "</li>";
        }
        return template + "</ul>";
    }
 
</script>

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 25 Feb 2015, 07:08 AM
Hello Leya,

As we have discussed in the support ticket you have opened on the same matter, this is not supported. It may by workaround to a degree, having in mind that the number of columns cannot vary on per row basis. Also binding/editing on indexers is not supported. The attached project do illustrate a possible way to workaround this limitation however you should note that this scenario is unsupported and you should use this on your own risk. 

Regards,
Rosen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Leya
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or