700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > jstree 选中指定节点-yellowcong

jstree 选中指定节点-yellowcong

时间:2022-07-29 23:07:30

相关推荐

jstree 选中指定节点-yellowcong

项目中使用的树框架是Jstree,经常会遇到默认选中节点的问题,刚开始使用Jstree的同学,肯定是会被官方的API坑哭了,JsTree官方API,这篇文章介绍jstree 默认某个节点选中,和如何用一个id做多次创建Tree数据

例子

$('#dailogTvmTree').jstree({'core': {'check_callback':true,'multiple':false,"expand_selected_onload":true,'data': treeData },}).on('select_node.jstree', function (e, data) {}).on("loaded.jstree", function (event, data) {//这两句化是在loaded所有的树节点后,然后做的选中操作,这点是需要注意的,loaded.jstree 这个函数//取消选中,然后选中某一个节点$("#dailogTvmTree").jstree("deselect_all",true);//$("#keyKamokuCd").val()是选中的节点id,然后后面的一个参数 true表示的是不触发默认select_node.change的事件 $('#dailogTvmTree').jstree('select_node',$("#keyKamokuCd").val(),true);});

使用后的结果

注意

当时多次调用创建树节点,并使用的是同一个ID的时候,一定要销毁tree

//这两句是销毁dialog和销毁树,我们使用下一句$(this).dialog('destroy');$('#dailogTvmTree').jstree("destroy");

$('#' + dialog).dialog({title: "xx結果",bgiframe: true, modal: true,draggable: true,resizable: false,autoOpen:false,width: 1000,height: 710,overlay:{ opacity:0.5, background:'#C0C0C0' },close: function () {$(this).dialog('destroy');$('#dailogTvmTree').jstree("destroy");}});$('#' + dialog).dialog("open");

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。