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

Binding selected item in treeview to form

1 Answer 177 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Irit
Top achievements
Rank 1
Irit asked on 21 Jan 2013, 02:01 PM
Hello,

I'm trying to bind the selected item in a tree to an object in my ViewModel and I fail to do that. 

I tried to use this in my markup:
<div class="todo-tree" data-bind="source: todoList, value: selectedTask" ></div>

But I guess it is not the correct way, since I get the following error:
Uncaught TypeError: Object [object Object] has no method 'value'

I that matters, my data source is a simple array.

Did anyone did that before and can assist?

Thanks,
Irit

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 23 Jan 2013, 11:27 AM
Hello Irit,

Such error usually occurs when observable object from one ViewModel (or DataSource) is assigned to another View-Model instance. Please make sure that the TreeView source and the selected item are part of the same View-Model.

For your convenience I prepared a small example. I hope this will help.

Best 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
Irit
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or