Hello,
as demonstrated in this fiddle, using an existing HTML table for Grid definition will only work when creating the grid using the $("#grid").kendoGrid() syntax. Using the kendo.bind($("#grid"), viewModel) syntax will result in the column headers being overwritten. I've traced this to the call to Grid.setDataSource() from the MVVM framework. Stacktrace as follows (version 2012.2.823):
As a matter of fact, any call to Grid.setDataSource() after widget initialization will result in the headers being overwritten. The method used to detect a pre-existing HTML header (in Grid._thead()) fails when that header has been moved to a separate div by the init code.
On the assumption that the table header should only be initialized once, the attached patch for kendo.all.js seems to fix this immediate problem by checking for an existing thead. I've not done any testing beyond verifying that the table headers are kept intact, so breakage elsewhere may occur.
Regards,
Stig
as demonstrated in this fiddle, using an existing HTML table for Grid definition will only work when creating the grid using the $("#grid").kendoGrid() syntax. Using the kendo.bind($("#grid"), viewModel) syntax will result in the column headers being overwritten. I've traced this to the call to Grid.setDataSource() from the MVVM framework. Stacktrace as follows (version 2012.2.823):
Widget.extend.setDataSource (kendo.all.js:16654)
binders.widget.source.Binder.extend.refresh (kendo.all.js:7740)
Class.extend.bind (kendo.all.js:7109)
BindingTarget.extend.applyBinding (kendo.all.js:7931)
BindingTarget.extend.bind (kendo.all.js:7910)
bindElement (kendo.all.js:8065)
bind (kendo.all.js:8088)
(anonymous function) (gridtest.html:23)
As a matter of fact, any call to Grid.setDataSource() after widget initialization will result in the headers being overwritten. The method used to detect a pre-existing HTML header (in Grid._thead()) fails when that header has been moved to a separate div by the init code.
On the assumption that the table header should only be initialized once, the attached patch for kendo.all.js seems to fix this immediate problem by checking for an existing thead. I've not done any testing beyond verifying that the table headers are kept intact, so breakage elsewhere may occur.
Regards,
Stig