本文将带您了解关于BootstrapTreeView标签name=parentNode引起页面卡死的新内容,同时我们还将为您解释bootstraphr标签的相关知识,另外,我们还将为您提供关于boot
本文将带您了解关于Bootstrap TreeView 标签name=parentNode引起页面卡死的新内容,同时我们还将为您解释bootstrap hr标签的相关知识,另外,我们还将为您提供关于bootstrap ace treeview组件的使用、bootstrap treeview 扩展addNode方法动态添加子节点、bootstrap treeview 扩展addNode方法动态添加子节点的方法、bootstrap treeview 树形数据生成的实用信息。
本文目录一览:- Bootstrap TreeView 标签name=parentNode引起页面卡死(bootstrap hr标签)
- bootstrap ace treeview组件的使用
- bootstrap treeview 扩展addNode方法动态添加子节点
- bootstrap treeview 扩展addNode方法动态添加子节点的方法
- bootstrap treeview 树形数据生成
Bootstrap TreeView 标签name=parentNode引起页面卡死(bootstrap hr标签)
一次使用TreeView 插件时遇到问题如下:
页面使用了TreeView相关js和css;
表单中出现:
<select required name="parentNode" id="parentNode"onchange="selectParentMenu(this)">
<option value="0">root根目录</option> <option value="1">选择目录</option>
</select>
其中: name="parentNode"导致页面卡死状态;
总结
以上是小编为你收集整理的Bootstrap TreeView 标签name=parentNode引起页面卡死全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
原文地址:https://www.cnblogs.com/ygzhaof/p/11401075.html
bootstrap ace treeview组件的使用
总结
以上是小编为你收集整理的bootstrap ace treeview组件的使用全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
bootstrap treeview 扩展addNode方法动态添加子节点
本文主要介绍了
本文只是详细说明对bootstrap-treeview添加子节点的扩展方法(addNode),如了解bootstrap-treeview所有用法请看官方API
官方api https://www.npmjs.com/package/bootstrap-treeview (点击新窗口打开)
使用过程中,需要动态添加子节点。发现api中没有此功能。找了很多资料也没有发现有相关的方法。
又不想放弃使用它,看来只能自己写的。先读他们的源代码,看他们的逻辑关系,然后就下手自己写一下。不多说,直接上代码
第一步:在Tree主函数return {/*在这里添加addNode的入口*/}
看图比较直观
附上代码:
addNode: $.proxy(this.addNode, this),
第二步:添加Tree的prototype方法
/** 给节点添加子节点 @param {Object|Number} identifiers - A valid node, node id or array of node identifiers @param {optional Object} options.node; */ Tree.prototype.addNode = function (identifiers, options) { this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { this.setAddNode(node, options); }, this)); this.setInitialStates({ nodes: this.tree }, 0); this.render(); } /** * 添加子节点 */ Tree.prototype.setAddNode = function (node, options) { if (node.nodes == null) node.nodes = []; if (options.node) { node.nodes.push(options.node); }; };
看图:
第三步:就是如何使用了。
$("#Treeview01").treeview("addNode", [2, { node: { text: "新加的菜单", href: "001005" } }]);
注意 $("#Treeview01")使用data已初始化过的
下面看个实例TreeView动态添加节点
遍历某路径下的文件夹添加父节点,遍历文件夹下的文件添加子节点
private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog fd = new FolderBrowserDialog(); if (fd.ShowDialog() == DialogResult.OK) { // 在此添加代码,选择的路径为 folderBrowserDialog1.SelectedPath if (Directory.Exists(fd.SelectedPath)) { DirectoryInfo thisOne = new DirectoryInfo(fd.SelectedPath); DirectoryInfo[] directoryInfo = thisOne.GetDirectories(); for (int i = 0; i < directoryInfo.Length; i++) { TreeNode root = new TreeNode(directoryInfo[i].ToString());//创建节点 root.Name = directoryInfo[i].ToString(); //为节点取个名字,这儿创建的是根节点 root.Tag = 0; treeView1.Nodes.Add(root); //将节点添加到treeView1上 DirectoryInfo thisTwo = new DirectoryInfo(fd.SelectedPath + "\\" + directoryInfo[i].ToString()); FileInfo[] fileInfo = thisTwo.GetFiles(); for (int j = 0; j < fileInfo.Length; j++) { TreeNode node = new TreeNode(fileInfo[j].ToString()); node.Tag = 1; node.Name = fileInfo[j].ToString(); if (!root.Nodes.ContainsKey(node.Name)) { root.Nodes.Add(node); } } } } } }
相关推荐:
Bootstrap treeview实现动态加载数据及快捷搜索功能的实现
实例详解BootStrap TreeView使用方法
bootstrap中插件treeview的介绍与使用
以上就是
bootstrap treeview 扩展addNode方法动态添加子节点的方法
bootstrap-treeview是一款效果非常酷的基于bootstrap的jQuery多级列表树插件。该jQuery插件基于Twitter Bootstrap,以简单和优雅的方式来显示一些继承树结构,如视图树、列表树等等。
本文只是详细说明对bootstrap-treeview添加子节点的扩展方法(addNode),如了解
官方api (点击新窗口打开)
使用过程中,需要动态添加子节点。发现api中没有此功能。找了很多资料也没有发现有相关的方法。
又不想放弃使用它,看来只能自己写的。先读他们的源代码,看他们的逻辑关系,然后就下手自己写一下。不多说,直接上代码
第一步:在Tree主函数return {/*在这里添加addNode的入口*/}
看图比较直观
附上代码:
第二步:添加Tree的prototype方法
看图:
第三步:就是如何使用了。
注意 $("#Treeview01")使用data已初始化过的
下面看个实例TreeView动态添加节点
遍历某路径下的文件夹添加父节点,遍历文件夹下的文件添加子节点
总结
以上所述是小编给大家介绍的bootstrap treeview 扩展addNode方法动态添加子节点的方法。小编 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得小编不错,可分享给好友!感谢支持。
bootstrap treeview 树形数据生成
这个问题还是挺经典的,后台只是负责查出所有的数据,前台js来处理数据展示给treeview;show you the code below:<script> $(function () { getData(); }) var displaySeach = function(){ if($("#search-page .x_content").is(":hidden")) $(‘#search-page .x_content‘).slideDown(300); else $(‘#search-page .x_content‘).slideUp(300); } function getTree() { //节点上的数据遵循如下的格式: var tree = [{ text: "场地列表",//节点显示的文本值 string icon: "glyphicon glyphicon-play-circle",//节点上显示的图标,支持bootstrap的图标 string selectedIcon: "glyphicon glyphicon-ok",//节点被选中时显示的图标 string color: "#ff0000",//节点的前景色 string backColor: "#1606ec",//节点的背景色 string selectable: true,//标记节点是否可以选择。false表示节点应该作为扩展标题,不会触发选择事件。 string state: { //描述节点的初始状态 Object checked: true,//是否选中节点 /*disabled: true,*/ //是否禁用节点 expanded: true,//是否展开节点 selected: true //是否选中节点 } }] return tree; } function getData() { $.ajax({ type: "GET",url: "/serverPoint/index",success: function (data) { console.log("data",data); for (var k = 0; k < data.length; k++) { data[k][‘text‘] = data[k][‘Name‘]; } var tree = [{ text: "场地列表",//节点显示的文本值 string icon: "glyphicon glyphicon-play-circle",//节点上显示的图标,支持bootstrap的图标 string selectedIcon: "glyphicon glyphicon-ok",//节点被选中时显示的图标 string color: "#ff0000",//节点的前景色 string backColor: "#1606ec",//节点的背景色 string selectable: true,//标记节点是否可以选择。false表示节点应该作为扩展标题,不会触发选择事件。 string state: { //描述节点的初始状态 Object checked: true,//是否选中节点 /*disabled: true,*/ //是否禁用节点 expanded: true,//是否展开节点 selected: true //是否选中节点 },nodes: toTree(data) }] $(‘#tree‘).treeview({ data: tree,//节点数据 showBorder: true,//是否在节点周围显示边框 showCheckBox: true,//是否在节点上显示复选框 showIcon: true,//是否显示节点图标 highlightSelected: true,levels: 2,multiSelect: true,//是否可以同时选择多个节点 showTags: true }); },error: function () { $.pnotify({ title: ‘失败提醒‘,text: ‘请求服务器失败‘,type: ‘error‘,nonblock: { nonblock: false },}); } }); } function toTree(data) { // 删除 所有 children,以防止多次调用 data.forEach(function (item) { delete item.nodes; }); // 将数据存储为 以 id 为 KEY 的 map 索引数据列 var map = {}; data.forEach(function (item) { map[item.ID] = item; });// console.log(map); var val = []; data.forEach(function (item) { // 以当前遍历项,的pid,去map对象中找到索引的id var parent = map[item.ParentID]; // 好绕啊,如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中 if (parent) { (parent.nodes || (parent.nodes = [])).push(item); } else { //如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级 val.push(item); } }); return val; } $(‘.place-choice‘).on(‘change‘,function () { var cityNum = $(this).val(); console.log("cityNum:",cityNum); addplaceSelect($(this),cityNum); }); var addplaceSelect = function (obj,cityNum) { console.log("addplaceSelect...................."); obj.nextAll().remove(); $.ajax({ url: ‘/serverPoint/getChild/‘ + cityNum,type: ‘get‘,data: {},success: function (data) { if (data) { if (data.length > 0) { console.log(‘data.length > 0‘); var select = $(‘<select></select>‘); select.addClass(‘select2_single form-control place-choice‘).css(‘margin-right‘,‘5px‘).css(‘width‘,‘100px‘).css(‘float‘,‘left‘); $(‘.place-choice-td‘).append(select); select.on(‘change‘,function () { var cityNum = $(this).val(); addplaceSelect($(this),cityNum); }); var str = ‘<option value="">请选择</option>‘; select.append(str); for (var i = 0; i < data.length; i++) { var str = ‘<option value="‘ + data[i][‘ID‘] + ‘">‘ + data[i][‘Name‘] + ‘</option>‘; select.append(str); } } } else { $.pnotify({ title: ‘失败提醒‘,text: ‘添加分类失败‘,}); } },error: function () { $.pnotify({ title: ‘失败提醒‘,nonblock: { nonblock: false },}); } }); } function addNode(pid=null) { var parentId=‘‘; if (pid == -1) { var text = $(‘#postition-name‘).val(); console.log(‘text:‘,text); parentId = 0; if (text == "" || text.length == 0) { $.pnotify({ title: ‘温馨提醒‘,text: ‘请先填写名称‘,}); return; } } else { parentId = $(‘.place-choice-td select:last-child‘).val(); console.log(parentId); var text = $(‘#sub-postition-name‘).val(); if (parentId == "" || parentId.length == 0) { $.pnotify({ title: ‘温馨提醒‘,text: ‘请先选择场景‘,}); return; } if (text == "" || text.length == 0) { $.pnotify({ title: ‘温馨提醒‘,}); return; } } $.ajax({ url: ‘/serverPoint/add‘,type: ‘post‘,data: { ‘parentId‘: parentId,‘name‘: text },success: function (data) { $.pnotify({ title: ‘成功提醒‘,text: ‘添加成功‘,type: ‘success‘,}); getData(); },}); } }); } /* function getTree() { //节点上的数据遵循如下的格式: var tree = [{ text: "Node 1",//节点显示的文本值 string icon: "glyphicon glyphicon-play-circle",//节点上显示的图标,支持bootstrap的图标 string selectedIcon: "glyphicon glyphicon-ok",//节点被选中时显示的图标 string color: "#ff0000",//节点的前景色 string backColor: "#1606ec",//节点的背景色 string href: "#http://www.baidu.com",//节点上的超链接 selectable: true,//标记节点是否可以选择。false表示节点应该作为扩展标题,不会触发选择事件。 string state: { //描述节点的初始状态 Object checked: true,//是否选中节点 /!*disabled: true,*!/ //是否禁用节点 expanded: true,//是否展开节点 selected: true //是否选中节点 },//tags: [‘标签信息1‘,‘标签信息2‘],//向节点的右侧添加附加信息(类似与boostrap的徽章) Array of Strings nodes: getData() }] return tree; }*/ /*function getData(){ $.ajax({ type: "GET",success:function(data){ console.log(JSON.stringify(data)); return JSON.stringify(data); },error:function() { } }); }*/</script>
今天的关于Bootstrap TreeView 标签name=parentNode引起页面卡死和bootstrap hr标签的分享已经结束,谢谢您的关注,如果想了解更多关于bootstrap ace treeview组件的使用、bootstrap treeview 扩展addNode方法动态添加子节点、bootstrap treeview 扩展addNode方法动态添加子节点的方法、bootstrap treeview 树形数据生成的相关知识,请在本站进行查询。
本文标签: