Last Updated: 01 Jul 2021 11:02 by ADMIN
Created on: 14 Jan 2014 22:52
Category: UI for ASP.NET MVC
Type: Feature Request
AutooGenerateColumns should support column names with spaces
Just getting started with Kendo Grid - below is my VB.NET razor code (I know, I know) working against a System.Data.DataTable for a model. 

The DataTable contains columns in it where some of the ColumnNames have spaces. The web page successfully renders my table, but, it errors due to the Kendo's row template, it seems.

    Dim mainGrid = Html.Kendo().Grid(Model.MainTable) _
         .Name("Grid") _
                  End Sub) _
                     End Sub) _
        .Pageable() _
        .Sortable() _
Viktor Tachev
Posted on: 01 Jul 2021 11:02

Hi Brian,

The Grid component and also the DataSource were designed in a way that spaces in property names are not available out of the box. This is because the components can be used in a vast number of scenarios and should be able to handle all of them.

That said, if spaces are available you can use the described approach.


Viktor Tachev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Posted on: 15 Jan 2014 22:06
I'm also finding if I go into the src javascript for kendo.web.js (scroll down to line 7594) and I add this line to detect spaces, my DataTable driven Kendo Grids render a lot more happily in MSIE and Firefox

                        //add these 2 lines after var fromName - i.e. after line 7594
                        if (field.indexOf(" ") > -1)
                            field = "['" + field + "']";
Posted on: 15 Jan 2014 15:44
If I supply my own ClientRowTemplate, then it starts to work better- IMHO this template should be the standard OOTB behavior.. as I belive this style of template logic will work across the board.

    Dim sb As New StringBuilder("<tr  data-uid=""#=data.uid#"" role='row'>")
    For Each c In Model.MainTable.Columns
        sb.AppendFormat("<td role='gridcell'>#:data['{0}']==null?'':data['{0}']#</td>", c.ColumnName)
Posted on: 15 Jan 2014 14:43
I came across this snippet for how to do client script of field names with spaces and will see if this can be obtained using the server wrapper somehow
Posted on: 14 Jan 2014 23:01
As I continue experimentation, it seems to be a limitation in regard to how a System.Data.DataTable can be bound (i.e. - not specific to AutoGenerateColumns) - I have highly engineered T-SQL statements producing data with specific column names (using square brackets allows returned column names to have spaces in it) and those columns are simply coming straight into my System.Data.DataTable as-is.. but the Kendo UI Grid ASP.NET server wrapper cannot seem to parse it successfully.