I am attempting to create a treeview of Document libraries from SharePoint (wss3).
- the icons i specified in the types plugin are not rendering? I am probably missing something so simple.
How can I inject more nodes into the tree when i expand a folder or document library?
TreeView">$(document).ready(function () {
var thisSite = $().SPServices.SPGetCurrentSite(); $().SPServices({ operation: "GetListCollection", webURL: thisSite, async: false, completefunc: function (xData, Status) { var list = new Array(); var $json = $.xmlToJSON(xData.responseXML); $.each($json.Body[0].GetListCollectionResponse[0].GetListCollectionResult[0].Lists[0].List, function (index, value) { if (value.ServerTemplate == 101) { var listid = value.ID.replace("{", ""); listid = listid.replace("}", ""); var treeID = value.Title.replace(/ /g, ""); var item = { "data": value.Title, "state": "closed", "attr": { "id": listid, "rel": "list" } }; list.push(item); var s = $('#TreeViewTemplate').parseTemplate(item); $("#docHTML").append(s); $('#' + treeID + "TreeView").jstree({ types: { valid_children: ["list"], max_depth: -2, max_children: -2, types: { list: { icon: { image: "/_layouts/images/itdl.gif" }, valid_children: ["folder", "file"], max_depth: -2, max_children: -2, select_node: function (e) { $('#RightArea').append("List</br>"); this.toggle_node(e); return false; } }, folder: { icon: { image: "/_layouts/images/folder.png" }, valid_children: ["folder", "file"], max_depth: -2, max_children: -2, open_node: function () { $('#RightArea').append("folder</br>"); return false; } }, file: { icon: { image: "/_layouts/images/page_white.png" }, valid_children: ["none"], max_depth: 0, max_children: 0, open_node: function () { $('#RightArea').append("file</br>"); return false; } } } }, json_data: { data: [ item ] }, plugins: ["themes", "json_data", "types", "ui"] }); } }); // var dt = { "Lists": $json.Body[0].GetListCollectionResponse[0].GetListCollectionResult[0].Lists[0].List }; } }); $().SPServices({ operation: "GetAllSubWebCollection", webURL: thisSite, async: false, completefunc: function (xData, Status) { var $json = $.xmlToJSON(xData.responseXML); var dt = { "Sites": $json.Body[0].GetAllSubWebCollectionResponse[0].GetAllSubWebCollectionResult[0].Webs[0].Web }; var s = $('#SiteTemplate').parseTemplate(dt); $("#siteHTML").html(s); } }); $().SPServices({ operation: "GetListCollection", webURL: thisSite, async: false, completefunc: function (xData, Status) { var $json = $.xmlToJSON(xData.responseXML); var dt = { "Lists": $json.Body[0].GetListCollectionResponse[0].GetListCollectionResult[0].Lists[0].List }; var s = $('#ListTemplate').parseTemplate(dt); $("#listHTML").html(s); } }); // $('#docHTML .treeview').treeview({ // collapsed: true, // speed: 1, // toggle: function () { // if (this.role == "List") { // GetItemsInList(this.id, this.title, this.parentNode.id, this.role, ""); // } // else if (this.role == "Folder") { // var splt = this.path.split("#"); // var splt1 = splt[1].split("/"); // GetItemsInList(splt1[0], this.title, this.treeviewid, this.role, splt[1]); // } // } // }); $('#accordion').accordion({ clearSytle: true, fillSpace: true });
});