我有一个列表视图我希望用户能够双击这将改变树视图的数据源并选择一个树视图节点。当我得到我想要选择的项目的ID时,执行我认为应该在树视图上选择节点的代码,它不会选择。任何想法将不胜感激
Listview双击事件:
function setItemDoubleClickEvent() {
$(".machineInstances").on("dblclick", function () {
var listView = $("#listView").data("kendoListView");
var idx = $(this).index();
var item = listView.dataSource.view()[idx];
$('#selectedNodeId').val(item.InstanceId);
// Remove the current datasource to remove any existing filtering
$("#treeview").data("kendoTreeView").setDataSource([]);
// Set the hidden input so OnData knows what to highlight
$('#selectedNodeId').val(item.InstanceId);
// Set the new datasource for the tree
$("#treeview").data("kendoTreeView").setDataSource(instanceDataSource); });
}
TreeView声明:
var treeview = $("#treeview").kendoTreeView({
dataTextField: "Name"
, select: onSelect,
dataBound: ondata
}).data("kendoTreeView"),
DataBound功能:
function ondata() {
//alert($('#selectedNodeId').val());
var selected = $('#selectedNodeId').val();
if (selected != "") {
var node = treeview.findByUid(selected)
$("#treeview").data("kendoTreeView").select(node);
$('#selectedNodeId').val("");
}
}
谢谢,
德鲁