当前位置:首页 » 操作系统 » ztree数据库

ztree数据库

发布时间: 2022-09-22 05:42:51

1. 谁会做zTree。 树菜单选中保存进数据库。下次加载树菜单打开时,还是显示的是:勾选着上次选中保存的

数据已经保存进数据库了是吧!
然后只需要在查询树的方法里写sql;
sql包含树中展示的所有数据以及选中的数据,只需在选中的数据后面拼接checked:true就行了

2. java做Ztree显示方面的问题 怎么让Ztree显示数据库的值 请大神帮忙

1、把setting里async这个去掉,或把async.enable设成false
2、在init前面加上
var zNodes = "<%=zNodess%>";

3. 用ztree 在java里面 从数据库中读取数据 求大神给具体代码 要有详细注释的

你把类型强转改成request.getAttribute("jsonArray").toString()试试
或者你前台其实就要个String ,你setAtribute时先用jsonArray的toString()方法把他转为字符串再set进来不就不用再jsp类型转换了!

4. Ztree如何实现点击左边 + 号图标号后从数据库动态获取子节点数据,显示出来

最简单的办法,其实就是拼写字符串,你怎么拼出来 web页面的html内容的?? 那么只需要按照 json格式拼出全部字符串即可。

可以参考 异步加载 Demo 中得到的数据(请利用 chrome 的调试工具进行跟踪调试)

如果对象比较复杂,那么可以在谷歌上搜索一下:“java json 输出” 会有很多教程和 lib 推荐

5. java做Ztree显示方面的问题 怎么让Ztree显示数据库的值

你把类型强转改成request.getAttribute("jsonArray").toString()试试
或者你前台其实就要个String ,你setAtribute时先用jsonArray的toString()方法把他转为字符串再set进来不就不用再jsp类型转换了

6. ztree 怎么与数据库交互

1、调整 Css 即可
2、zTree 的拖拽操作可以灵活实现改变父节点的操作
3、zTree 的编辑功能是删除整个节点(包括其下属分支),需要自己利用 zTree 提供的方法灵活使用即可实现
4、每次操作后,自己利用 ajax 与后台交互就可以实现显示数据域数据库交互了。

7. 在ztree中怎么从数据库中获取数据展示出来

var setting = {
checkable : true,
callback : {
onClick: zTreeOnClick
},
expandSpeed :"fast",
async: {
enable: true,
url:"getTreeNode.jsp",
autoParam:["id","name"],
dataFilter: null
},
view: {
showLine: false,
dblClickExpand :false
}};
$.fn.zTree.init($("#sidebar"), setting);
希望你能看得懂~

8. 使用zTree 生成的文件树该怎么存放至数据库

能说说看这个是什么应用场景吗?说清楚的话可能比较有针对性的探讨。

如果类似于p2p软件的共享 可能这些数据保存在客户端比较合适.例如cookie什么的,
不过cookie也有它的局限性,会给清理,保存内容有限 等等 不过4kb似乎也够了

这些文件目录是非固定的吧?

是的,非固定的目录与文件。

有一点像是杀毒软件的架构……

jquert-filetree.js

// jQuery File Tree Plugin
//
// Version 1.01
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 24 March 2008
//
// Visit http://abeautifulsite.net/notebook.php?article=58 for more information
//
// Usage: $('.fileTreeDemo').fileTree( options, callback )
//
// Options: root - root folder to display; default = /
// script - location of the serverside AJAX file to use; default = jqueryFileTree.php
// folderEvent - event to trigger expand/collapse; default = click
// expandSpeed - default = 500 (ms); use -1 for no animation
// collapseSpeed - default = 500 (ms); use -1 for no animation
// expandEasing - easing function to use on expand (optional)
// collapseEasing - easing function to use on collapse (optional)
// multiFolder - whether or not to limit the browser to one subfolder at a time
// loadMessage - Message to display while initial tree loads (can be HTML)
//
// History:
//
// 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
// 1.00 - released (24 March 2008)
//
// TERMS OF USE
//
// This plugin is al-licensed under the GNU General Public License and the MIT License and
// is right 2008 A Beautiful Site, LLC.
//
if(jQuery) (function($){

$.extend($.fn, {

fileTree: function(o) {

var EXCLUDED = 0;

var INCLUDED = 1;

var PARTIAL = 2;

// Defaults

if( !o ) var o = {};

if( o.root == undefined ) o.root = '/';

if( o.script == undefined ) o.script = 'jqueryFileTree.php';

if( o.folderEvent == undefined ) o.folderEvent = 'click';

if( o.expandSpeed == undefined ) o.expandSpeed= 500;

if( o.collapseSpeed == undefined ) o.collapseSpeed= 500;

if( o.expandEasing == undefined ) o.expandEasing = null;

if( o.collapseEasing == undefined ) o.collapseEasing = null;

if( o.multiFolder == undefined ) o.multiFolder = true;

if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';

$(this).each( function() {

function showTree(c, t) {

$(c).addClass('wait');

$(".jqueryFileTree.start").remove();

$.post(o.script, { action: 'file_tree', dir: t }, function(data) {

$(c).find('.start').html('');

$(c).removeClass('wait').append(data);

if( o.root == t ) $(c).find('UL:hidden').show(); else $(c).find('UL:hidden').slideDown({ ration: o.expandSpeed, easing: o.expandEasing });

//Check that the list of files that we got from the server have not already

//been included or excluded in the UI.

$('.checkbox').each(function () {
var dir = escape(dirname($(this).attr('rel')));
if (dir == t) {
var state = get_include_state($(this).attr('rel'));
if (state !== false) {
set_checkbox_state(this, state);
}
}

});

bindTree(c);

});

}

function bindTree(t) {

$(t).find('LI A.tree').bind(o.folderEvent, function() {

if( $(this).parent().hasClass('directory') ) {

if( $(this).parent().hasClass('collapsed') ) {

// Expand

if( !o.multiFolder ) {

$(this).parent().parent().find('UL').slideUp({ ration: o.collapseSpeed, easing: o.collapseEasing });

$(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed');

}

$(this).parent().find('UL').remove(); // cleanup

showTree( $(this).parent(), escape($(this).attr('rel').match( /.*\// )) );

$(this).parent().removeClass('collapsed').addClass('expanded');

} else {

// Collapse

$(this).parent().find('UL').slideUp({ ration: o.collapseSpeed, easing: o.collapseEasing });

$(this).parent().removeClass('expanded').addClass('collapsed');

}

} else {

var element = $(this).parent().find('.checkbox');

if (element.length) {

checkbox_click(element);

}

}

return false;

});

//Bind our check box clicks

$(t).find('ul').find('.checkbox').bind('click', function() {

checkbox_click(this);

});

// Prevent A from triggering the # on non-click events

if( o.folderEvent.toLowerCase != 'click' ) $(t).find('LI A').bind('click', function() { return false; });

}

// Loading message

$(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');

// Get the initial file list

showTree( $(this), escape(o.root) );

});

/**

* Updates the tri state check box based on the state hidden element passed

* @param check_box

*/

function set_checkbox_state(check_box, new_state) {

new_state = parseInt(new_state);

$(check_box).removeClass('checked');

$(check_box).removeClass('partial');

switch(new_state) {

case EXCLUDED:

$(check_box).addClass('checked');

break;

case PARTIAL:

$(check_box).addClass('partial');

break;

default:

break; //INCLUDED - Do nothing

}

}

/**

* Toggles the hidden list input with what has changed

* @param element

*/

function set_include_state(element) {
var file = $(element).attr('rel');
var state = get_checkbox_state(element);

var file_tree_list = JSON.parse($('#file_tree_list').val());

var in_list = false;
for (var i = 0; i < file_tree_list.length; i++) {

if (file_tree_list[i][0] == file) {

file_tree_list[i][1] = state;
in_list = true;

break;

}

}
if (!in_list) {
file_tree_list.push([file, state])
}

$('#file_tree_list').val(JSON.stringify(file_tree_list));

}

/**

* Get the file state from the local list

* @param file

* @return int

*/

function get_include_state(file) {

var file_list = JSON.parse($('#file_tree_list').val());

for (var i = 0; i < file_list.length; i++) {

if (file_list[i][0] == file) {

return file_list[i][1];

}

}

return false;

}

/**

* Just like PHP's dirname

* @param path

*/

function dirname(path) {

return path.replace(/\/$/, '').replace(/\/[^\/]*$/, '/');

}

/**

* Toggles the directory check box to ON, OFF or PARTIAL depending on the state of all its children.

* @param clicked

*/

function toggle_directory_check(clicked) {

//Also check its directory if they are all not checked

var checked_count = 0, total = 0;

var clicked_parent_dir = dirname($(clicked).attr('rel'));

$('.checkbox').each(function () {

if (clicked_parent_dir != o.root) {

var parent_dir = dirname($(this).attr('rel'));

if (parent_dir == clicked_parent_dir) {

var state = get_checkbox_state(this);

if (state == PARTIAL || state == EXCLUDED) {

checked_count++;

}

total++;

}

}

});

//Now that we know that the state of all the directories children we can update the parent dir accordingly

$('.checkbox').each(function () {

if ($(this).attr('rel') == clicked_parent_dir) {

if (checked_count == total) {

set_checkbox_state(this, EXCLUDED);
} else if (checked_count == 0) {

set_checkbox_state(this, INCLUDED);

} else {

set_checkbox_state(this, PARTIAL);

}
set_include_state(this);

toggle_directory_check(this);

}

});

}

/**

* Return the current state of a clicked check box

* @param clicked

*/

function get_checkbox_state(clicked) {

var state = INCLUDED;

if ($(clicked).hasClass('partial')) {

state = PARTIAL;

} else if ($(clicked).hasClass('checked')) {

state = EXCLUDED;

}

return state;

}

/**

* Set all the children of a directory to a state

* @param parent

*/

function set_directory_children(parent, state) {

//If this is an expanded directory recursively update all its children

if ($(parent).parent().hasClass('expanded') && $(parent).hasClass('directory')) {

$('.checkbox').each(function () {

if (dirname($(this).attr('rel')) == $(parent).attr('rel')) {

set_checkbox_state(this, state);

set_include_state(this);

set_directory_children(this, state);

}

});

}

}

/**

* The on click function for a file check box. If the user clicks on a directory then all its open children

* need to be updated accordingly.

* @param clicked

*/

function checkbox_click(clicked) {

var state = get_checkbox_state(clicked) == EXCLUDED ? INCLUDED : EXCLUDED;

set_checkbox_state(clicked, state);

set_include_state(clicked);

set_directory_children(clicked, state);
toggle_directory_check(clicked);

}

}

});

})(jQuery);

9. ztree如何动态获取数据库数据(java后台)

不知道你说的动态是指初始化 , 还是初始化赋值

如果是初始化 , 在js中先到后台查询数据 , 拿到返回的数据后 , 再初始化ztree

如果是数据回显 , 就是说手动选中某些节点 , 可以用 checkNode 方法 ,

具体可以看API :

既然用到ztree , 肯定有很多方法需要知道的 , 我当初刚用的时候就是一点一点看API来写的

热点内容
内置存储卡可以拆吗 发布:2025-05-18 04:16:35 浏览:336
编译原理课时设置 发布:2025-05-18 04:13:28 浏览:378
linux中进入ip地址服务器 发布:2025-05-18 04:11:21 浏览:612
java用什么软件写 发布:2025-05-18 03:56:19 浏览:32
linux配置vim编译c 发布:2025-05-18 03:55:07 浏览:107
砸百鬼脚本 发布:2025-05-18 03:53:34 浏览:944
安卓手机如何拍视频和苹果一样 发布:2025-05-18 03:40:47 浏览:741
为什么安卓手机连不上苹果7热点 发布:2025-05-18 03:40:13 浏览:803
网卡访问 发布:2025-05-18 03:35:04 浏览:511
接收和发送服务器地址 发布:2025-05-18 03:33:48 浏览:372