public static List <JsTreeNode> add_Nodes(this JsTree jsTree, params string[] titles)
        {
            var newJsTreeNodes = new List <JsTreeNode>();

            foreach (var title in titles)
            {
                newJsTreeNodes.Add(jsTree.add_Node(title));
            }
            return(newJsTreeNodes);
        }
		public JsTree JsTreeWithFoldersAndGuidanceItems()
		{			
    		var jsTree = new JsTree();
			var libraries = GetLibraries();
			Func<Guid, List<Folder_V3>, JsTreeNode, List<Guid>> mapFolders = null;
			Func<Guid, Guid, List<Guid>, JsTreeNode, List<Guid>> mapViews = null;

			//precalculate for performance reasons
			var allViews = new Dictionary<Guid, View_V3>();
			foreach(var view in javascriptProxy.GetViews())
				allViews.Add(view.viewId, view);

			mapViews = (libraryId, folderId, viewIds, targetNode) =>
				{
					var viewsId = new List<Guid>();
					foreach(var viewId in viewIds)
					{
						var view = allViews[viewId];//GetViewById(viewId.str());
						
						var viewNodeText =  view.viewId.str();												
						var viewNode = targetNode.add_Node(view.caption, viewNodeText);						
						viewNode.state = "closed";
						viewNode.data.icon = "/Images/ViewIcon.png";												
						viewsId.add(view.viewId);
					}
					return viewsId;
				};
			
			mapFolders = (libraryId, folders, targetNode)=>
				{
					var folderViewsId = new List<Guid>();
					foreach(var folder in folders)
					{
						var subFolderViewsId  = new List<Guid>();
						var folderId = folder.folderId;
						var folderNode = targetNode.add_Node(folder.name);						
						folderNode.state = "closed";
						folderNode.data.icon = "/Images/FolderIcon.png";
						subFolderViewsId.AddRange(mapFolders(libraryId, folder.subFolders, folderNode));
						var viewIds = (from view in folder.views
									   select view.viewId).toList();
						subFolderViewsId.AddRange(mapViews(libraryId, folderId, viewIds, folderNode));
						
						folderNode.attr.id = folderId.str();												
						folderViewsId.AddRange(subFolderViewsId);					
					}
					return folderViewsId;
					
				};
			
			foreach(var library in libraries)
			{				
				var libraryNode =jsTree.add_Node(library.Caption);
				var mappedFolders = new Dictionary<string, List<Folder_V3>>();				
				mapFolders(library.Id, javascriptProxy.GetFolders(library.Id), libraryNode);
				mapViews(library.Id, Guid.Empty, javascriptProxy.GetViewsInLibraryRoot(library.Id.str()).guids(), libraryNode);
				//libraryNode.state = "open";
				libraryNode.state = "closed";
				libraryNode.data.icon = "/Images/SingleLibrary.png";
				
				var libraryNodeText = library.Id.str();										
				
				libraryNode.attr.id = libraryNodeText;
				
			}					
			return jsTree;
		}
Beispiel #3
0
 public static JsTreeNode add_Node(this JsTree jsTree, string title)
 {
     return(jsTree.add_Node(title, ""));
 }