private TreeView GenerateTreeview() { var tvOptions = new Entity.TreeViewOptions() { AlbumId = _albumId, SelectedAlbumIds = _albumIdsToSelect, NumberOfLevels = _numberOfLevels, EnableCheckboxPlugin = _showCheckbox, IncludeAlbum = _includeAlbum, NavigateUrl = _navigateUrl, RequiredSecurityPermissions = _securityAction, RootNodesPrefix = RootNodesPrefix, Galleries = (_albumId > 0 ? null : _galleries) }; return(AlbumTreeViewBuilder.GetAlbumsAsTreeView(tvOptions)); }
///// <summary> ///// Render the treeview to two levels - the root album and its direct children. If the AlbumIdsToCheck property ///// has items in its collection, make sure every album in the collection is rendered, no matter how deep in the album heirarchy ///// they may be. If the albumToSelect parameter is specified, then make sure this album is rendered and ///// selected/checked, no matter how deep in the hierarchy it may be. ///// </summary> //public void BindTreeView() //{ // //BindTreeView(null); //} ///// <summary> ///// Render the treeview to two levels - the root album and its direct children. If the <see cref="CheckedAlbumIds" /> property ///// has items in its collection, make sure every album in the collection is rendered, no matter how deep in the album heirarchy ///// they may be. If the <paramref name="albumToSelect" /> parameter is specified, then make sure this album is rendered and ///// selected/checked, no matter how deep in the hierarchy it may be. ///// </summary> ///// <param name="albumToSelect">An album to be selected, checked, and made visible. The treeview is automatically expanded as ///// needed to ensure this album is visible.</param> //public void BindTreeView(IAlbum albumToSelect) //{ // //this._albumToSelect = albumToSelect; // //DataBindTreeView(); // //this._albumToSelect = null; // //this.AlbumIdsToCheck.Clear(); //} #endregion #region Private Methods /// <summary> /// Gets a JSON-formatted string of data that can be assigned to the data property of a /// jsTree jQuery instance. /// </summary> /// <returns>A string formatted as JSON.</returns> /// <exception cref="System.InvalidOperationException">Thrown when one or more business rules /// are violated.</exception> private string GetTreeData() { #region Validation if (!this.AllowMultiCheck && this.SelectedAlbumIds.Count > 1) { throw new InvalidOperationException("The property AllowMultiCheck must be false when multiple album IDs have been assigned to the property SelectedAlbumIds."); } if (!SecurityActionEnumHelper.IsValidSecurityAction(this.RequiredSecurityPermissions)) { throw new InvalidOperationException("The property GalleryServer.Web.Controls.albumtreeview.RequiredSecurityPermissions must be assigned before the TreeView can be rendered."); } #endregion TreeViewOptions tvOptions = new TreeViewOptions() { SelectedAlbumIds = SelectedAlbumIds, NumberOfLevels = NumberOfLevels, NavigateUrl = NavigateUrl, EnableCheckboxPlugin = EnableCheckboxPlugin, IncludeAlbum = IncludeAlbum, RequiredSecurityPermissions = RequiredSecurityPermissions, AlbumId = AlbumId, RootNodesPrefix = RootNodesPrefix, Galleries = Galleries }; Entity.TreeView tv = AlbumTreeViewBuilder.GetAlbumsAsTreeView(tvOptions); //if (_nodesToCheckIds == null) // _nodesToCheckIds = new List<string>(tv.NodesToCheckIdArray.Count); //_nodesToCheckIds.AddRange(tv.NodesToCheckIdArray); return(tv.ToJson()); }