[jquery] jQuery jsTree V3.2.1 基礎Demo


 

引入對應的文件:

<link rel="stylesheet" href="../dist/themes/default/style.min.css" />
	<script src="../dist/jquery-2.1.4.min.js"></script>
	<script src="../dist/jstree.min.js"></script>

 


                $("#deptIdModify").jstree({

                    "core" : {
                        'multiple':false,//單選,true 為多選
                        "data": {
                            "url" :"../common/getSelectByCodeId2?codeId=PSB",
                            'dataType':'json',
                            'data' : function (node) {
                                return { 'id' : node.id};
                            }
                        }
                    },
                    "plugins" : [ "wholerow", "checkbox" ]
                });
deptIdModify 可以為:

div,ul其他沒有試過。

使tree節點選中..
$("#deptIdModify").jstree(true).check_node(data.formData.deptCode);

 但是上面的選擇有一個問題,第一次打開頁面無法選中,修改后如下:

$("#deptIdModify").jstree({

                    "core" : {
                        'multiple':false,
                        "data": {
                            "url" :"../common/getSelectByCodeId2?codeId=PSB",
                            'dataType':'json',
                            'data' : function (node) {
                                return { 'id' : node.id};
                            }
                        }
                    },
                    "plugins" : [ "wholerow", "checkbox" ]
                }).bind("loaded.jstree",function(){
                    var node = data.formData.deptCode;
                    $("#deptIdModify").jstree("check_node",node);
                });

 

 

取值:

var deptIds=$("#deptIdModify").jstree(true).get_selected();

 

其他知API,詳細配置信息 可訪問官網:

 jstree 官網:https://www.jstree.com/

 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM