ztree鑺傜偣鎼滅储鍔熻兘濡備綍瀹炵幇
zTree 鎻愪緵浜嗕竴涓悕涓?searchNode
鐨勬柟娉曟潵鎼滅储鑺傜偣锛岃鏂规硶鎺ュ彈涓€涓瓧绗︿覆浣滀负鍙傛暟锛岀敤浜庢寚瀹氳鎼滅储鐨勫叧閿瘝銆傚綋璋冪敤 searchNode
鏂规硶鏃讹紝zTree 浼氭牴鎹寚瀹氱殑鍏抽敭璇嶅湪鎵€鏈夎妭鐐圭殑鍚嶇О涓繘琛屾悳绱紝骞跺皢鍖归厤鐨勮妭鐐归珮浜樉绀恒€?/p>
浠ヤ笅鏄竴涓畝鍗曠殑绀轰緥浠g爜锛屾紨绀哄浣曚娇鐢?searchNode
鏂规硶鏉ュ疄鐜拌妭鐐规悳绱㈠姛鑳斤細
// 鍒濆鍖?zTree
var zNodes = [
{ name:"鑺傜偣1", open:true, children: [ { name:"瀛愯妭鐐?" } ] },
{ name:"鑺傜偣2", open:true, children: [ { name:"瀛愯妭鐐?" } ] },
{ name:"鑺傜偣3", open:true, children: [ { name:"瀛愯妭鐐?" } ] }
];
var setting = {
data: {
simpleData: {
enable: true
}
}
};
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
var zTreeObj = $.fn.zTree.getZTreeObj("treeDemo");
// 瀹炵幇鑺傜偣鎼滅储鍔熻兘
function searchNode() {
var keyword = $("#keyword").val();
zTreeObj.searchNode(keyword);
}
// 鐩戝惉鎼滅储鎸夐挳鐐瑰嚮浜嬩欢
$("#searchBtn").click(function() {
searchNode();
});
鍦ㄤ笂闈㈢殑绀轰緥涓紝鎴戜滑棣栧厛鍒濆鍖栦簡涓€涓?zTree锛屽苟涓烘悳绱㈡寜閽粦瀹氫簡涓€涓偣鍑讳簨浠剁洃鍚櫒銆傚綋鐢ㄦ埛鍦ㄨ緭鍏ユ涓緭鍏ュ叧閿瘝骞剁偣鍑绘悳绱㈡寜閽椂锛岃皟鐢?searchNode
鏂规硶杩涜鑺傜偣鎼滅储銆傛悳绱㈢粨鏋滀細鍦?zTree 涓珮浜樉绀哄尮閰嶇殑鑺傜偣銆?/p>