问题
I have main page: main.html
In this page I have a viewmodel with a hierarchical datasource
datasource: [{id:"", items:[{.....}]}];
In a modal window I have a Treeview. Treeview call a datasource in main page.
In my datasource there is a variable check: true/false
I want that when I check or uncheck a checkbox in the treeview this bind a datasource.. so when I close a modal window, and the I re-open it I will find the selected/unselected checkbox restored...
回答1:
If you have an HTML like this:
<div id="win" class="k-content">
<div id="treeview"></div>
</div>
Where you have a kendoWindow
which id is win
containing a kendoTreeView
with id treeview
, you should initialize them using:
var treeview = $("#treeview").kendoTreeView({
checkboxes: {
checkChildren: true
},
dataSource: data
}).data("kendoTreeView");
var kwin = $("#win").kendoWindow({
visible : true,
modal : true,
resizable: false
}).data("kendoWindow");
And no matter if the DataSource
for the tree
is local (array) or remote. Since you are not going to be destroying the window, just opening and closing, the data is always there.
Running example here
来源:https://stackoverflow.com/questions/14560431/kendo-treeview-datasource-binding