varsetting ={view: {dblclickexpand:true,//Double-click ExpandShowlayer:false, Selectedmulti:false,//whether to allow multiple selectionsShowicon:showiconfortree//Show node Small icon}, Data: {simpledata: {enable:true, IdKey:"id", PIdKey:"PId", Rootpid:"0"}}, callback: {Beforeclick:beforeclick, OnClick : OnClick}}; //loads the tree structure information list for the current project functionLoadstructureinfotreejson (ProjectID) {$.ajax ({type:"POST", DataType:"JSON", URL:".. /tools/structuremodel.ashx ", data: {act:"Loadmodeltreebyprojectid", Pid:projectid}, Success:function(data) {if(Data.length = = 0) { } Else{$.fn.ztree.init ($ ("#tree"), setting, data); varZtree = $.fn.ztree.getztreeobj ("tree");//Get Ztree Object varnode = ztree.getnodebyparam (' id ', 1);//get the point with ID 1Ztree.selectnode (node);//Select PointZTree.setting.callback.onClick (NULL, zTree.setting.treeId, node);//Invoke Event}}, Error:function() {alert ("There is a problem loading the tree structure!" "); } }); } functionShowiconfortree (Treeid, TreeNode) {returnTreenode.isparent;//If the parent node displays small icons};
Original link: http://blog.csdn.net/a15937822658/article/details/17759995
Ztree automatically click on the first node (reprint)