似乎无法将节点添加到剑道UI树视图
Cannot seem to add Node to Kendo UI TreeView
>我试图将文本框中的节点添加到现有的树视图
输入
<input id="appendNodeText" value="Node" class="k-textbox">
按钮
<button type="button" class="btn btn-blue" id="addTopLevel">Add Top Level Menu</button>
JavaScript
<script>
// button handler
$("#addTopLevel").click(append);
handleTextBox = function (callback) {
return function (e) {
if (e.type != "keypress" || kendo.keys.ENTER == e.keyCode) {
callback(e);
}
};
};
var append = handleTextBox(function (e) {
var selectedNode = treeview.select();
console.log(selectedNode);
// passing a falsy value as the second append() parameter
// will append the new node to the root group
if (selectedNode.length == 0) {
selectedNode = null;
}
treeview.append({
text: $("#appendNodeText").val()
}, selectedNode);
});
所以我最终有这个点击事件,它在其中"追加"传递
老实说,我不明白句柄文本框,也不明白附加
树视图确实"有效",但我想知道它是否是问题的一部分
var treeview = $("#treeview").kendoTreeView({
expanded: true,
dragAndDrop: true,
dataSource: homogeneous,
dataTextField: "ReportGroupName" //"name" //"id" // "FullName"
,
change: function(e) {
console.log("Change", this.select());
}
});
每个答案:
我试过这个
$("#addTopLevel").click(function () {
console.log('in this');
if (treeview.select().length) {
console.log('1');
treeview.append({
text: $("#appendNodeText").val()
}, treeview.select());
} else {
//alert("please select tree node");
console.log('2');
}
});
控制台.log写出"在此"然后写出"1"
所以我什至没有选择任何节点....一定是出了什么问题
这是我的 JSON
[{"Id":1,"ReportGroupName":"Standard Reports","ReportGroupNameResID":null,"SortOrder":1},{"Id":2,"ReportGroupName":"Custom Reports","ReportGroupNameResID":null,"SortOrder":2},{"Id":3,"ReportGroupName":"Retail Reports","ReportGroupNameResID":null,"SortOrder":3},{"Id":4,"ReportGroupName":"Admin Reports","ReportGroupNameResID":null,"SortOrder":5},{"Id":5,"ReportGroupName":"QA Reports","ReportGroupNameResID":null,"SortOrder":4}]
据我了解,您希望将文本框值作为节点附加到树视图中的选定节点。 我已经为具有工作功能的相同创建了一个JSFIDDLE:-
http://jsfiddle.net/GHdwR/468/
点击事件按钮:-
$("#addTopLevel").click(function() {
if (treeview.select().length) {
treeview.append({
text: $("#appendNodeText").val()
}, treeview.select());
} else {
alert("please select tree node");
}
});
- 如何设置默认<ui视图>在另一<ui视图>
- 如何在ui路由器angularjs中只更改子ui视图,同时保持父视图不变
- 如何在具有某些 UI 视图的状态中管理工厂单个请求数据
- 如何加载嵌套3个状态的UI路由器UI视图模板
- 为什么我的html页面没有在<ui视图>
- 为什么我的视图没有显示在角度ui视图中
- 角度 ui 视图(UI 路由器)未呈现模板 - 包括 plunker
- NG-单击不触发,深入 UI 视图
- 另一个 UI 视图中的角度 UI 视图
- 更改ng包含或定义默认ui视图
- Angularjs UI视图和Rails服务器端模板路由
- ng使用ui视图制作动画
- 更改状态时保持同级ui视图-ui路由器
- 角度 ui 路由器:为孩子保留相同的 ui 视图
- 保持主 UI 视图不变
- 在ui路由器中,从较低状态覆盖处于较高状态的布局视图会导致ui视图为空
- AngularJS ui视图未接收范围
- AngularJS将ui视图嵌套到ng repeat中
- Angular UI路由器未将页脚注入UI视图
- 在ui视图内部使用ng-include时出错