當前位置:首頁 » 操作系統 » 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