You can store the reference to the grid in an observable in your view model like so:
function ViewModel() {
// ....
self.grid = ko.observable();
}
and your HTML would be
<div data-bind="kendoGrid: {data:filteredItems, pageable: { buttonCount: 5, pageSize: 5 }, widget: grid }" />
Now, once the grid has been instantiated, you can reference it with self.grid()
instead of $("#MyGrid").data("kendoGrid")
- it's a looser coupling between your view model and your view because you don't have to hardcode a jQuery selector.
I've updated your fiddle to reflect these changes.
You can find the documentation for the widget
option at the bottom of this page in the Knockout-Kendo documentation