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

Existing HTML table header overwritten by MVVM binding

0 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stig
Top achievements
Rank 1
Stig asked on 30 Aug 2012, 07:42 PM
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):

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

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Stig
Top achievements
Rank 1
Share this question
or