kendo Treeview数据源绑定 [英] kendo Treeview datasource binding
问题描述
我有主页:main.html
I have main page: main.html
在此页面中,我有一个带有分层数据源的视图模型
In this page I have a viewmodel with a hierarchical datasource
datasource: [{id:"", items:[{.....}]}];
在模式窗口中,我有一个Treeview. Treeview在主页上调用数据源.
In a modal window I have a Treeview. Treeview call a datasource in main page.
在我的数据源中有一个变量检查:true/false
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...
推荐答案
如果您有这样的HTML:
If you have an HTML like this:
<div id="win" class="k-content">
<div id="treeview"></div>
</div>
如果您的ID为win
的kendoWindow
包含ID为treeview
的kendoTreeView
,则应使用以下命令对其进行初始化:
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");
tree
的DataSource
是本地(数组)还是远程.由于您不会破坏窗口,只需打开和关闭窗口,数据就始终存在.
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.
运行示例此处
这篇关于kendo Treeview数据源绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!