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

buttons in <th> tags don't always work

1 Answer 13 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 30 Sep 2012, 10:15 PM
When I make an html table a grid by  setting data-role="grid", the <th> tags can no longer support working buttons which are bound by the viewModel. The following jsfiddle illustrates the issue: http://jsfiddle.net/billmcknight/zHKtb/  As you can see in the plain table the buttons in the <th> tag can be bound to the view model and do work (i.e. call the view model method)  But in the second table where the only change is to set the data-role = grid, the button can no longer be bound by the view model.  Why does it work this way?

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 04 Oct 2012, 07:30 AM
Hi Bill,

This is happening because after the initialization the Grid modifies the DOM - e.g. the original table is split into two separate tables, one for .k-grid-header and one for .k-grid-content. As a result the MVVM skips to bind the header. A possible solution is to bind .k-grid-header element manually:
kendo.bind($("#example"), viewModel);
kendo.bind($(".k-grid .k-grid-header"), viewModel);

For convenience I updated your fiddle: http://jsfiddle.net/valchev/zHKtb/8/

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Bill
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or