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

binding two dimensional string data dynamically to kendo mvc grid

1 Answer 425 Views
Grid
This is a migrated thread and some comments may be shown as answers.
riz
Top achievements
Rank 1
riz asked on 13 Apr 2018, 10:10 PM
Hello, I have a two-dimensional string array that I want to bind to kendo mvc grid. It contains two rows. It's able to display the first row as Header, but it's no not showing the second row. Following is my code for the view which receives the said two-dim string array:

@using Kendo.Mvc.UI

@model string[][]


@if (Model != null)
{
    
    var grid = Html.Kendo().Grid<dynamic>(Model)
        .Name("importGridHeader")
        .Columns(columns =>
        {
            var row = Model[0];
            foreach (var col in row)
            {
                columns.Bound(col).Width(200);
            }
        }
        )
        .HtmlAttributes(new { style = "min-height: 450px; max-height:1250px;" })
        .Sortable()
        .Scrollable(s => s.Enabled(true))
        .Resizable(r => r.Columns(true))
        .Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .ServerOperation(false)
         );
    grid.Render();
}

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 18 Apr 2018, 02:02 PM
Hello,

Each row from the Model collection bound to the Grid must contain property corresponding to the field name of the column. More information on this matter could be found in the following help topic:
If the above is not applicable in your case you could consider the approach demonstrated in the following HowTo example, where the data is populated in DataTable, but this is applicable for ASP.NET MVC helpers, because there is no built-in support for DataTable with the current version:

Best Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular 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
riz
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or