Kendo ui 剑道UI重新加载树视图
我通过ajax使用剑道ui加载一个复杂的树视图,因为我需要用一个请求加载树(工作正常): 如果我在通过ajax更改一些数据后尝试重新加载完整的树,那么新的构建树将无法正常工作,并且不会更新文本Kendo ui 剑道UI重新加载树视图,kendo-ui,Kendo Ui,我通过ajax使用剑道ui加载一个复杂的树视图,因为我需要用一个请求加载树(工作正常): 如果我在通过ajax更改一些数据后尝试重新加载完整的树,那么新的构建树将无法正常工作,并且不会更新文本 $.ajax({ type: 'POST', url: 'ajax/ajax_update_layer.php', data: { layerid:id, ... }, su
$.ajax({
type: 'POST',
url: 'ajax/ajax_update_layer.php',
data: {
layerid:id,
...
},
success: function(data){
buildTree();
}
});
我能做什么?
谢谢
斯文我让我的工作
这就是我所做的:
创建树视图的函数:
function CreateNotificationTree(userId)
{
var data = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "../api/notifications/byuserid/" + userId,
contentType: "application/json"
}
},
schema: {
model: {
children: "notifications"
}
}
});
$("#treeview").kendoTreeView({
dataSource: data,
loadOnDemand: true,
dataUrlField: "LinksTo",
checkboxes: {
checkChildren: true
},
dataTextField: ["notificationType", "NotificationDesc"],
select: treeviewSelect
});
function treeviewSelect(e)
{
var $item = this.dataItem(e.node);
window.open($item.NotificationLink, "_self");
}
}
修改和数据源刷新:
$('#btnDelete').on('click', function()
{
var treeView = $("#treeview").data("kendoTreeView");
var userId = $('#user_id').val();
$('#treeview').find('input:checkbox:checked').each(function()
{
var li = $(this).closest(".k-item")[0];
var notificationId = treeView.dataSource.getByUid(li.getAttribute('data-uid')).ID;
if (notificationId == "undefined")
{
alert('No ID was found for one or more notifications selected. These notifications will not be deleted. Please contact IT about this issue.');
}
else
{
$.ajax(
{
url: '../api/notifications/deleteNotification?userId=' + userId + '¬ificationId=' + notificationId,
type: 'DELETE',
success: function()
{
CreateNotificationTree(userId);
alert('Delete successful.');
},
failure: function()
{
alert('Delete failed.');
}
});
treeView.remove($(this).closest('.k-item'));
}
});
});
希望对您有所帮助。在ajax成功回调上尝试此功能
var data = $("#treeView").data('kendoTreeView');
data.dataSource.read();
有趣的是,我想做完全相同的事情。我从树中删除了一些节点,然后尝试调用构建它的函数,但它没有按预期工作。不幸的是,在剑斗技能方面,stackoverflow是缺乏的。
var data = $("#treeView").data('kendoTreeView');
data.dataSource.read();