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

JavaScript Error when grid binds to DataTable

1 Answer 31 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Maxim
Top achievements
Rank 1
Maxim asked on 15 Jun 2012, 12:33 PM
Hello!

I have this definition for the Grid:
@(Html.Telerik().Grid(Model.GridDataTable)
          .Name("Grid")    
          .Columns(columns =>
           {
               foreach (System.Data.DataColumn column in Model.GridDataTable.Columns)
               {
                   columns.Bound(column.DataType, column.ColumnName);    
               }
           })
                     .Pageable()
                          .Sortable()
                          .Filterable()
                          .Groupable()
    )

The Grid is in the TabStrip, so I can not switch between tabs in the TabStrip after adding Grid definition to content of some tab.

Also JS error has appeared:
Uncaught SyntaxError: Unexpected identifier
b.grid.valueFor
b.grid.initializeColumns.p
e.extend.proxy.g asset.axd:2
e.extend.each asset.axd:2
b.grid.initializeColumns
b.grid
a.fn.tGrid.b.create.init
a.telerik.create asset.axd:5
e.extend.each asset.axd:2
e.fn.e.each asset.axd:2
a.telerik.create asset.axd:5
a.fn.tGrid
(anonymous function)
ax asset.axd:5
a.ajax.success asset.axd:5
f.Callbacks.n asset.axd:2
f.Callbacks.o.fireWith asset.axd:2
w asset.axd:4
f.support.ajax.f.ajaxTransport.send.d asset.axd:4

I saw your "Grid Binding to DataTable Sample" and it works fine. I have not found a difference with my code.
What could be the problem?

Very thanks,
Max

1 Answer, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 1
answered on 19 Jul 2012, 11:26 PM
I also hit this issue with the Q2 2012 release.  In our case one of the columns in the DataTable, had a space in its name. It is created from a sproc, and bound to the grid.
  
The offending column's JS looked like this:
{"title":"Test Hours","member":"Test Hours","type":"String"}

After I updated the sproc to not have a space in the column name everything worked as expected, and the working JS looked like this:
{"title":"Test Hours","member":"TestHours","type":"String"}

It looks like the Title is getting an additional space when the column name already has a space, and it appears having a space in the column/member name causes issues in the grid.  

Hopefully this helps track down the issue :)
-Josh
Tags
Grid
Asked by
Maxim
Top achievements
Rank 1
Answers by
Joshua
Top achievements
Rank 1
Share this question
or