Jquery 搜索节点不';t自动展开文件夹或显示子计数器
我已从以下链接复制了fancytree过滤器功能的一些代码: 我将筛选功能注入到我构建的树中,但当我为某个项目筛选树时,文件夹不会自动展开,子计数器也不会出现 我安装的: jquery.fancytree-all-deps jquery.fanctree.filter jquery-2.2.0 jquery-ui-1.11.1 我尝试安装在我上面指定的链接的源代码中指定的版本,但没有帮助。有什么不合适的地方吗?我将过滤器属性放置在正确的位置,包括过滤器扩展,并包括向上键方法以从用户收集数据 我试图用这棵树做的所有其他事情我都能做到,但这似乎让我绊倒了。任何帮助都会很好Jquery 搜索节点不';t自动展开文件夹或显示子计数器,jquery,fancytree,Jquery,Fancytree,我已从以下链接复制了fancytree过滤器功能的一些代码: 我将筛选功能注入到我构建的树中,但当我为某个项目筛选树时,文件夹不会自动展开,子计数器也不会出现 我安装的: jquery.fancytree-all-deps jquery.fanctree.filter jquery-2.2.0 jquery-ui-1.11.1 我尝试安装在我上面指定的链接的源代码中指定的版本,但没有帮助。有什么不合适的地方吗?我将过滤器属性放置在正确的位置,包括过滤器扩展,并包括向上键方法以从用户收集数据 我试
$(function () {
$("#tree").fancytree({
extensions: ["filter"],
quicksearch: true,
filter: {
autoApply: true, // Re-apply last filter if lazy data is loaded
autoExpand: true, // Expand all branches that contain matches while filtered
counter: true, // Show a badge with number of matching child nodes near parent icons
fuzzy: false, // Match single characters in order, e.g. 'fb' will match 'FooBar'
hideExpandedCounter: true, // Hide counter badge if parent is expanded
hideExpanders: false, // Hide expanders if all child nodes are hidden by filter
highlight: true, // Highlight matches by wrapping inside <mark> tags
leavesOnly: false, // Match end nodes only
nodata: true, // Display a 'no data' status node if result is empty
mode: "dimm" // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
},
icon: false,
checkbox: true,
selectMode: 3,
source: treeStruc,
lazyLoad: function (event, data) {
var dfd = new $.Deferred();
data.result = dfd.promise();
scope.tree.parentSelectionState = data.node.data.preselected;
GetElementsForTree(data.node.key).done(function (value, dataReturned) {
var lazyNodeValues = [];
for (var l = 0; l < value.length; l++) {
var element = value[l].Path.split('\\');
element = element[element.length - 1];
var obj = { title: element, key: value[l].Path, webId: value[l].WebId, preselected: scope.tree.parentSelectionState, lazy: true };
lazyNodeValues.push(obj);
}
dfd.resolve(lazyNodeValues);
});
},
loadChildren: function (event, data) {
// Apply parent's state to new child nodes:
data.node.fixSelection3AfterClick();$("#tree").fancytree("getTree").getNodeByKey(data.node.children[i].key).setExpanded(true);
}
}); //End of $#tree
$('#tree').removeClass('r-hidden');
var tree = $("#tree").fancytree("getTree");
/*
* Event handlers for our little demo interface
*/
$("input[name=search]").keyup(function (e) {
var n,
tree = $.ui.fancytree.getTree(),
args = "autoApply autoExpand fuzzy hideExpanders highlight leavesOnly nodata".split(" "),
opts = {},
filterFunc = $("#branchMode").is(":checked") ? tree.filterBranches : tree.filterNodes,
match = $(this).val();
$.each(args, function (i, o) {
opts[o] = $("#" + o).is(":checked");
});
opts.mode = $("#hideMode").is(":checked") ? "hide" : "dimm";
if (e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === "") {
$("button#btnResetSearch").click();
return;
}
if ($("#regex").is(":checked")) {
// Pass function to perform match
n = filterFunc.call(tree, function (node) {
return new RegExp(match, "i").test(node.title);
}, opts);
} else {
// Pass a string to perform case insensitive matching
n = filterFunc.call(tree, match, opts);
}
$("button#btnResetSearch").attr("disabled", false);
$("span#matches").text("(" + n + " matches)");
}).focus();
$("fieldset input:checkbox").change(function (e) {
var id = $(this).attr("id"),
flag = $(this).is(":checked");
// Some options can only be set with general filter options (not method args):
switch (id) {
case "counter":
case "hideExpandedCounter":
tree.options.filter[id] = flag;
break;
}
tree.clearFilter();
$("input[name=search]").keyup();
});
}); //End of $function
$(函数(){
$(“#树”).fancytree({
扩展名:[“筛选器”],
快速搜索:没错,
过滤器:{
autoApply:true,//如果加载了惰性数据,则重新应用最后一个筛选器
autoExpand:true,//在筛选时展开包含匹配项的所有分支
计数器:true,//在父图标附近显示具有匹配子节点数的标记
fuzzy:false,//按顺序匹配单个字符,例如“fb”将匹配“FooBar”
hideExpandedCounter:true,//如果父项已展开,则隐藏计数器标记
hideExpanders:false,//如果筛选器隐藏了所有子节点,则隐藏展开器
highlight:true,//通过包装内部标记高亮显示匹配项
levesonly:false,//仅匹配结束节点
nodata:true,//如果结果为空,则显示“无数据”状态节点
模式:“dimm”//Grayout非匹配节点(传递“hide”以删除非匹配节点)
},
图标:false,
复选框:正确,
选择模式:3,
资料来源:treeStruc,
lazyLoad:函数(事件、数据){
var dfd=新的$.Deferred();
data.result=dfd.promise();
scope.tree.parentSelectionState=data.node.data.preselected;
GetElementsForTree(data.node.key).done(函数(值,返回的数据){
var lazyNodeValues=[];
对于(var l=0;l
不确定这是否会导致问题,但如果您已经包含了jquery ui,则应该使用jquery.fancytree-all而不是jquery.fancytree-all-depsThanks来快速回复。我没有将筛选函数存储在变量中,而是在“$(“#regex”)的else子句中调用“$(“#tree”).fancytree(“getTree”).filterNodes(match,{autoExpand:true,leavesOnly:false}”);is(“:checked”)“if语句。此外,子计数问题是由于图标被设置为false。为了查看子计数,必须将图标设置为true。不确定这是否会导致问题,但如果已经包含jquery ui,则应使用jquery.fancytree-all而不是jquery.fancytree-all-depsThanks来快速回复。我没有将筛选函数存储在变量中,而是在“$(“#regex”)的else子句中调用“$(“#tree”).fancytree(“getTree”).filterNodes(match,{autoExpand:true,leavesOnly:false}”);is(“:checked”)“if语句。此外,子计数问题是由于图标被设置为false。为了查看子计数,必须将图标设置为true。