Tag: jstree

如何在jquery jstree中获取已检查的节点

我创建了一个jquery jstree,它工作正常。 现在问题是如何获取已检查节点的详细信息。 用于创建JStree代码是: $(function () { $(“#tree”).jstree({ “json_data” : { “data” : [ {“data”:”pe_opensourcescanning”,”id”:0,”pId”:-1,”children”: [{“data”:”tags”,”id”:30,”pid”:0},{“data”:”branches”,”id”:29,”pid”:0},{“data”:”trunk”,”id”:1,”pid”:0,”children”:[{“data”:”import-export”,”id”:28,”pid”:1},{“data”:”custom_development”,”id”:12,”pid”:1},{“data”:”Connectors”,”id”:7,”pid”:1},{“data”:”support”,”id”:6,”pid”:1},{“data”:”Installation-Configuration”,”id”:5,”pid”:1},{“data”:”backup”,”id”:2,”pid”:1}]}]} ] }, “plugins” : [ “themes”, “json_data”, “checkbox”, “ui” ] }).bind(“select_node.jstree”, function (e, data) { alert(data.rslt.obj.data(“id”)); }); 现在,在获取已检查的节点时,我需要这些已检查元素的所有属性值。 比如“标签”,json对象看起来像{“data”:“tags”,“id”:30,“pid”:0},所以如果用户选择标签我需要“data”和“id”的值。 我试图编写一些代码,但不幸的是,这是行不通的。 获取已检查的节点。 $(“#” +div2.childNodes[i].id).jstree(“get_checked”,null,true).each (function () { alert(this.data); alert(this.id); }); 请给我一个解决方案。

jsTree异步搜索 – 触发加载新节点

我有一个很好的运行jsTree实现在我的项目上运行。 JSON数据由PHP / Ajax提供。 我在使用搜索插件时遇到了一些麻烦。 jsTree的搜索插件文档说: 所以在你的响应中你必须返回节点的路径(没有节点本身)作为ids:[“#root_node”,“#child_node_3”] …所以,我的服务器端搜索function正在返回匹配节点的路径(是的,我是json_encode ): Array( ‘#1’, ‘#2’, ‘#3’, ‘#5’ ); // to match node #10 (leaf node) at the end 当这些值已经存在于DOM中时,客户端搜索function正常工作,但是我无法使jsTree遵循此数组(或数组)中提供的路由,以在元素尚不存在时填充树(例如,只有根节点打开时)。 我在Stack上看到了类似的问题,但没有任何答案。 我正在重新发布,因为我需要了解它是如何工作的,并且在搜索插件文档之后没有找到有关如何将jsTree与异步搜索结合使用的信息。 基本上我想要它做的是使用我的搜索函数返回的数组来触发jsTree的加载事件(类似于load_node_json ) – 我会认为这应该直接开箱即用,但我遇到了麻烦。 我刚刚插入了jsTree文档中的示例代码。

jsTree:如何从jstree获取所有节点?

如何让所有节点都出现在jsTree中? 我正在用xml构建jsTree Root —–A —–A1 —–A1.1 —–A1.2 —–A2 —–`A2.1` —–A2.2 —–B —–B1 —–B2 —–C —–C1 —–C1.1 —–C2.2 我想要jsTree中存在的所有节点(ID)的数组如下 预期产出:[Root,A,A1,A1.1,A1.2,A2,A2.1,A2.2,B,B1,B2,C,C1,C1.1,C2.2]

如何获取jsTree的元数据。

这是我的代码: $(“#demo1”).jstree({ “themes”: { “theme”: “default”, “dots”: true, “icons”: true, “url”: “static/themes/default/style.css” }, “ui” : { // this makes the node with ID node_4 selected onload “initially_select” : [ location.hash.slice(1).split(‘@’)[1]] }, “json_data” : { “data” : [ { “data” : “A node”, “attr” : { “id” : “1” ,time:1321}, “callback”:function(){alert(‘sss’)}, “children” : [ { “data” […]

获取jsTree的选中值 – 使用表单发布

我正在使用带有复选框主题的jsTree jQuery插件。 有谁知道如何使用表格post获取所选值? 谢谢!

如何在jstree中获取所有已检查的节点?

我需要像这样导出我的节点: function recursive_simplify(node){ if(node.children){ for(var i =0;i<node.children.length;i++){ node.children[i] = recursive_simplify(node.children[i]) } } delete node['metadata']; return node } $('body').on('click','.data-export', function () { var tree=$.jstree._reference('#reference-data-exchange'); var checked = tree.get_checked(); var result = []; for(var i=0, checkedLength = checked.length; i<checkedLength;i++) { var checkedJson = tree.get_json(checked[i],['id','rel','data-bin','data-pos'])[0]; checkedJson = recursive_simplify(checkedJson); result.push(checkedJson); } alert(JSON.stringify(result)); }); 它的工作正常,但是! 我需要所有已检查的节点(已检查和未确定)我的代码仅返回已检查。 Plz的帮助。

jsTree无法从AJAX调用加载根节点

我无法使用下面的jsTree加载初始根节点:数据在服务器上,并且必须通过AJAX为所选的每个节点“购买”。 我还想使用一个复选框并获取所选节点的所有父节点的值。 现在的主要问题是:我无法列出根节点…. //jsTree $(‘#testTree’).jstree({ ‘core’ : { ‘data’ : { ‘url’ : function (node) { return node.id === ‘#’ ? ‘/cgi-bin/test.pl’ //url for root nodes ‘/cgi-bin/test.pl?nodes-in-selected-heirarchy’; //url for children nodes }, ‘data’ : function (node) { console.log(‘node.id=’+node.id); return { ‘id’ : node.id }; } } } }); 所有这一切都是一个文件夹图标。 我从服务器获得的JSON是: {“5″:”summer”,”8″:”vacation”,”2″:”2015″,”3″:”2014″,”4″:”2013″,”6″:”winter”,”1″:”2016″,”7″:”birthday”} 它是一个key:value,格式。 这是一个新修改的代码:即使这不起作用…… $(‘#test’).jstree({ ‘core’: […]

使用存储在数组中的备用JSON格式创建动态jstree

我能够使用替代JSON格式创建jstree,如下所示: $(‘#using_json_2’).jstree({ ‘core’ : { ‘data’ : [ { “id” : “ajson1”, “parent” : “#”, “text” : “Simple root node” }, { “id” : “ajson2”, “parent” : “#”, “text” : “Root node 2” }, { “id” : “ajson3”, “parent” : “ajson2”, “text” : “Child 1” }, { “id” : “ajson4”, “parent” : “ajson2”, “text” : […]

jsTree和上下文菜单:修改项目

我正在使用jsTree 3.0.0 ,我需要通过以下方式之一修改上下文: 更改默认项目的标签语言,禁用某些默认项目并添加新项目。 重写所有项目并绑定到一些新项目的创建,重命名和删除function。 我尝试了几种方法但没有任何效果。 例如,这将返回Uncaught TypeError: Object [object global] has no method ‘create’当我单击create时, Uncaught TypeError: Object [object global] has no method ‘create’ 。 “contextmenu”:{ “items”: function($node) { return { createItem : { “label” : “Create New Branch”, “action” : function(obj) { this.create(obj); alert(obj.text())}, “_class” : “class” }, renameItem : { “label” : “Rename […]