I suggest you ...

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") _
.Columns(Sub(cols)
cols.AutoGenerate(True)
End Sub) _
.DataSource(Sub(dSource)
dSource.Ajax()
End Sub) _
.Pageable() _
.Sortable() _
.Filterable()

1 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Brian WattsBrian Watts shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    4 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Brian WattsBrian Watts commented  ·   ·  Flag as inappropriate

        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 + "']";

      • Brian WattsBrian Watts commented  ·   ·  Flag as inappropriate

        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)
        Next

        sb.AppendLine("</tr>")

      • Brian WattsBrian Watts commented  ·   ·  Flag as inappropriate

        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.

      Feedback and Knowledge Base