Mdb
Mdb

Reputation: 8568

Kendo Knockout: loading treeView with kendo.data.dataSource

Currently kendo-knockout library does not support passing kendo.data.dataSource into bindings. I was able to load the treeView with kendo data source using the widget reference sample in the update of my post here: Kendo-Knockout: use knockout view model with kendo datasource to populate kendoTreeView. But was unable to add and remove items to it as well as some other issues. I am writing this question based on a comment by RP Niemeyer in github:

https://github.com/rniemeyer/knockout-kendo/issues/6

saying that this should be possible if I pass something like data: false, dataSource: yourDataSource and this fiddle:

http://jsfiddle.net/rniemeyer/s5G5k/

Following this example I tried to make an implementation of the treeView:

http://jsfiddle.net/s5G5k/6/

but I am getting an error: Cannot call method 'toLowerCase' of undefined

So my question here is can this work and can I then add/remove objects to the dataSource and see the view updates accordingly? Thanks!

Upvotes: 0

Views: 2956

Answers (1)

RP Niemeyer
RP Niemeyer

Reputation: 114792

I really need to revisit adding the ability to pass a dataSource directly into the widgets.

One solution for now is to wrap your treeview in a "with" binding and have it get re-rendered when you add/remove items.

Maybe like:

<div data-bind="with: treeView">
    <div id="reportGrid" data-bind="kendoTreeView: { dataSource: treeViewDataSource }"></div>
</div>

http://jsfiddle.net/rniemeyer/6VZxB/

Upvotes: 3

Related Questions