0

I am trying to use kendoui DataSource together with my knockout viewmodel. It's very nice that I can just configure a kendoui DataSource and assign it to a kendoui grid's datasource.

But the data that is currently being shown in a kendoui grid (after being filtered, sorted and paged) is also important to the rest of my knockout viewmodel. For example there are items in the currently shown grid that are marked selected and it drives some other UI on the same page. Or the current page's items also have representative pictures showing in a different part of the UI. And as a general rule I am using knockout as my viewmodel and only deviating from it when I have to for things like kendoui grid.

How can I keep a knockout observableArray of items that are loaded in the kendoui grid in sync with the grid, including having observable items in the array that correspond to the data properties of the items in the grid. Ie., someone checks of an item in the grid and the corresponding property in the corresponding item in the observableArray changes.

I guess the question is how to keep kendoui's built-in observables in sync with a shadow knockout observable and observableArray.

I specifically want to use this approach in my durandaljs viewmodels.

Thanks

t316
  • 1,149
  • 1
  • 15
  • 28
  • why not just bind your kendoui grid to a knockout observablearray: http://rniemeyer.github.io/knockout-kendo/web/Grid.html – Tanner Feb 25 '14 at 15:33
  • I could but then I would needlessly duplicate all the paging, filtering, sorting protocol stuff that a kendoui datasource can do so seamlessly. I can catch all the kendoui datasource filter, page, sort, group parameters in a server side mvc controller action and apply them to the returned Iquerybale in a one-liner... The grid pager, filter textboxes, sorting is all auto-wired with server side filtering, sorting paging. If I did this in knockoutjs I would be in familiar territory but I would have to struggle to wire the grid's filter, group, sort, page UI elements to the knockout viewmodels. – t316 Feb 25 '14 at 15:48
  • It seems like the DataSource change event is promising to sync the datasource's current list of items with a knockout observablearray: http://docs.telerik.com/kendo-ui/api/framework/datasource#events-change. I'll give this a try and report back here. – t316 Feb 25 '14 at 16:35

0 Answers0