functiongetZtree() { varsetting = { view: { expandSpeed: 100, selectedMulti: true, showLine: true, // 是否显示节点间的连线 fontCss: {}, }, async: { type: "GET", enable: true, url: getRootPath() + "/upload/queryByZtree?speciaity=" + $("#speciaity").val(), // Ajax 获取数据的 URL 地址 autoParam: ["id=id"], dataFilter: filter }, data: { simpleData: { enable: true, idKey: "id", pIdKey: "pid", rootPId: '0' }, key: { name: "name" } }, callback: { onClick: selectOnClick, // 节点被点击时调用的方法 onAsyncSuccess: onAsyncSuccess } }; functiononAsyncSuccess(event, treeId, treeNode, msg) { varf = $("#add_fileid_id").val();//所选的ID 例如 "12589" vartreeObj = $.fn.zTree.getZTreeObj(treeId);//ztree树的ID varnode = treeObj.getNodeByParam("id", f);//根据ID找到该节点 treeObj.selectNode(node);//根据该节点选中 };