Class BaseTreeViewAnyController<T>
The controller for handling the IBaseTreeView<T> view
This controller/view allows the selection of entities of type T
that can be used for
sub-views accessing the SelectedItemForSubViews.
Thus all areas grids can be used (such as the default lookup views for selecting items for single lookup controls)
this view can also be used instead
Inheritance
BaseTreeViewAnyController<T>
Assembly: LemonEdge.ClientCore.dll
Syntax
public abstract class BaseTreeViewAnyController<T> : ModelViewController, ICollectionExportable, ISearchController, IModelViewController
Type Parameters
Name |
Description |
T |
The treeview works with any entity type T that has a parent relationship to
itself
|
Constructors
BaseTreeViewAnyController(IBaseTreeView<T>)
Creates a new tree view controller for the specified instance of a tree view
Declaration
public BaseTreeViewAnyController(IBaseTreeView<T> view)
Parameters
Type |
Name |
Description |
IBaseTreeView<T> |
view |
The instance of the tree view in the client application
|
Fields
_descriptor
Declaration
protected EntityDescriptor _descriptor
Field Value
_items
Declaration
Field Value
_rootNodes
Declaration
protected List<TreeNode<T>> _rootNodes
Field Value
Properties
AllowXMLImportExport
Declaration
public virtual bool AllowXMLImportExport { get; }
Property Value
AutoExpandAll
Indicates when loaded the system should automatically expand the entire tree view in the ui. Automated if the ui
view implements IBaseTreeViewWithExpansion<T>
Default is false
Declaration
protected virtual bool AutoExpandAll { get; }
Property Value
AutoPromptForLabelOnNew
Declaration
protected virtual bool AutoPromptForLabelOnNew { get; }
Property Value
CollectionType
Indicates we export a collection of entities of type T
Declaration
public Type CollectionType { get; }
Property Value
CommandAllowSearch
Declaration
protected virtual bool CommandAllowSearch { get; }
Property Value
CommandCopy
Provides the ability for an inheriting class to override the Copy command
Declaration
protected virtual ViewCommand CommandCopy { get; }
Property Value
CommandCopyAllow
Indicates if copying should be allowed in this view
Declaration
protected virtual bool CommandCopyAllow { get; }
Property Value
CommandDelete
Provides the ability for an inheriting class to override the Delete command
Declaration
protected virtual ViewCommand CommandDelete { get; }
Property Value
CommandDeleteAllow
Indicates if the view should show the Delete command - default is true
Declaration
protected virtual bool CommandDeleteAllow { get; }
Property Value
CommandDeleteCanDelete
Indicates if the view should allow items to be deleted - Default is true
Declaration
protected virtual bool CommandDeleteCanDelete { get; }
Property Value
CommandNew
Provides the ability for an inheriting class to override the New command
Declaration
protected virtual ViewCommand CommandNew { get; }
Property Value
CommandNewAllow
Indicates if the view should show the New command - Default is true
Declaration
protected virtual bool CommandNewAllow { get; }
Property Value
CommandNewAllowMultipleRoots
If true indicates the user can create multiple top level (root) nodes in the tree view. False otherwise
Default is true
Declaration
protected virtual bool CommandNewAllowMultipleRoots { get; }
Property Value
CommandNewCanCreate
Indicates if the view should allow New items to be created - Default is true
Declaration
protected virtual bool CommandNewCanCreate { get; }
Property Value
CommandNewType
Declaration
protected virtual Type CommandNewType { get; }
Property Value
CommandOpen
Provides the ability for an inheriting class to override the Open command
Declaration
protected virtual ViewCommand CommandOpen { get; }
Property Value
CommandOpenAllow
Indicates if the view should show the Open command - default is false
Declaration
public virtual bool CommandOpenAllow { get; }
Property Value
CommandRenameAllow
Declaration
protected virtual bool CommandRenameAllow { get; }
Property Value
CurrentGridItems
Holds the current complete collection of loaded tree nodes in the TreeView
Declaration
public IEnumerable CurrentGridItems { get; }
Property Value
Descriptor
The entity descriptor for the entity type T
that this tree view displays
Declaration
public EntityDescriptor Descriptor { get; }
Property Value
ForceSubViewUpdateOnChangeEvenIfSame
Declaration
protected virtual bool ForceSubViewUpdateOnChangeEvenIfSame { get; }
Property Value
GetDefaultOrder
Declaration
protected virtual Order? GetDefaultOrder { get; }
Property Value
GetDefaultOrderPropertyName
Declaration
protected virtual string GetDefaultOrderPropertyName { get; }
Property Value
GetParentIDPropertyName
Returns the property on the entity type T
that holds the relationship to the parent
instance of type T
too
Declaration
protected abstract string GetParentIDPropertyName { get; }
Property Value
GetTreeNodeColorPropertyName
Returns the property on the entity type T
that holds the color that should be shown as the
color on the tree node for every item in the tree view control itself
Declaration
public virtual string GetTreeNodeColorPropertyName { get; }
Property Value
GetTreeNodeIconPropertyName
Declaration
public virtual string GetTreeNodeIconPropertyName { get; }
Property Value
GetTreeNodeLabelPropertyName
Returns the property on the entity type T
that holds the string that should be shown as the
label on the tree node for every item in the tree view control itself
Declaration
public abstract string GetTreeNodeLabelPropertyName { get; }
Property Value
Declaration
public virtual string GetTreeNodeTooltipPropertyName { get; }
Property Value
IgnoreEvents
Declaration
protected bool IgnoreEvents { get; set; }
Property Value
LoadedItems
Declaration
protected IEnumerable<T> LoadedItems { get; }
Property Value
OnlyExportFromQuery
Indicates we should not only export data from the query
Declaration
public bool OnlyExportFromQuery { get; }
Property Value
OnlyExportGrid
Indicates we should not only export data from the view
Declaration
public bool OnlyExportGrid { get; }
Property Value
Indicates that when opening an item, instead of opening the actual entity T
, it should load
the item linked to by this property value on the entity T
Declaration
public virtual string OpenFromRelatedColumnName { get; }
Property Value
Indicates no pager is required, the tree view always loads all data
Declaration
public bool PagerRequired { get; }
Property Value
RenameHasOtherProperties
Declaration
protected virtual bool RenameHasOtherProperties { get; }
Property Value
Roots
List of root nodes displayed in tree
Declaration
public IReadOnlyList<TreeNode<T>> Roots { get; }
Property Value
SearchColumns
Declaration
public IEnumerable<string> SearchColumns { get; }
Property Value
SearchElements
Declaration
public IEnumerable<(string Name, string GroupKey, string FilterName, bool Visible)> SearchElements { get; }
Property Value
SearchGroups
Declaration
public IEnumerable<GridColumnGroup> SearchGroups { get; }
Property Value
SelectedItemForSubViews
Returns the actual entity T
of the currently selected tree node
Declaration
public override object SelectedItemForSubViews { get; }
Property Value
Overrides
TreeView
The instance of the tree view in the client application
Declaration
public IBaseTreeView<T> TreeView { get; }
Property Value
Methods
CanMoveAsChildOfItem(T, T)
Indicates this item is allowed to be moved to be a child of the specified parent item
Declaration
public virtual bool CanMoveAsChildOfItem(T moveItem, T newParentItem)
Parameters
Type |
Name |
Description |
T |
moveItem |
The item to be moved to be a child of the specified item
|
T |
newParentItem |
The item to become a parent of the item being moved
|
Returns
Type |
Description |
bool |
True if the moveItem can become a chile of the specified newParentItem
|
CanMoveToRoot(T)
Indicates this item is allowed to be moved to the root of the tree
Declaration
public virtual bool CanMoveToRoot(T item)
Parameters
Type |
Name |
Description |
T |
item |
The item to check if it can be moved to the root
|
Returns
Type |
Description |
bool |
True if the item can be moved to the root of the tree and is not already there
|
Clear()
Declaration
public override Task Clear()
Returns
Type |
Description |
Task |
A task indicating the completion of the operation
|
Overrides
CloseController()
Called when a view is being closed, and before the controller is disposed.
Used to dispose of associated commands and clear the view
Declaration
public override Task CloseController()
Returns
Type |
Description |
Task |
A task indicating the completion of the operation
|
Overrides
ColumnGroups()
Tree views have no arbitary grouping of the data
Declaration
public IEnumerable<GridColumnGroup> ColumnGroups()
Returns
CreateCopiedNode(TreeNode<T>, TreeNode<T>)
Declaration
protected virtual Task<TreeNode<T>> CreateCopiedNode(TreeNode<T> original, TreeNode<T> copiedParent)
Parameters
Returns
CreateWrapper(T, TreeNode<T>)
Declaration
protected virtual TreeNode<T> CreateWrapper(T item, TreeNode<T> parent)
Parameters
Type |
Name |
Description |
T |
item |
The item to be wrapped in a TreeNode<T>
|
TreeNode<T> |
parent |
An optional parent tree node this item is a child of
|
Returns
DisplayUI()
Loads all the entities of type T
for this tree view, wraps them in a
TreeNode<T> and displays them in the TreeView
Declaration
public override Task DisplayUI()
Returns
Type |
Description |
Task |
A task indicating the completion of the operation
|
Overrides
GetExportableColumnInfo(IEnumerable<ColumnDescriptor>)
Returns all properties of the entity type T
as being exportable
Declaration
public Task<IEnumerable<ControlDisplayVisibilityInfo>> GetExportableColumnInfo(IEnumerable<ColumnDescriptor> visibleColumns)
Parameters
Returns
GetIDValue(T)
Declaration
public abstract Guid GetIDValue(T item)
Parameters
Type |
Name |
Description |
T |
item |
|
Returns
GetQueryForExcelResults()
Returns the query used to load all the entities in the tree view display
Declaration
public virtual QueryableExecuter GetQueryForExcelResults()
Returns
GetTreeController(IBaseTreeView<T>)
Creates a new tree view controller with the specified instance of a tree view
Declaration
public static BaseTreeViewAnyController<T> GetTreeController(IBaseTreeView<T> view)
Parameters
Type |
Name |
Description |
IBaseTreeView<T> |
view |
The instance of the tree view in the client application
|
Returns
GetVisibleColumnNames()
Returns all properties of the entity type T
as being exportable
Declaration
public Task<IEnumerable<ControlDisplayInfo>> GetVisibleColumnNames()
Returns
HasLazyChildrenToLoad(TreeNode<T>)
Declaration
public virtual bool HasLazyChildrenToLoad(TreeNode<T> item)
Parameters
Returns
InitCommands(IList<ViewCommand>)
Adds the following commands: Open, New, Delete, MoveUp, MoveDown, and Export Data
Declaration
protected override void InitCommands(IList<ViewCommand> commands)
Parameters
Overrides
LazyLoadChildren(TreeNode<T>)
Declaration
public virtual Task<IEnumerable<TreeNode<T>>> LazyLoadChildren(TreeNode<T> node)
Parameters
Returns
LoadDataForCopyingNode(TreeNode<T>)
Declaration
protected virtual Task LoadDataForCopyingNode(TreeNode<T> node)
Parameters
Returns
LoadItems()
The method used by DisplayUI() to load all the entities for this tree view
Declaration
protected virtual Task<IEnumerable<T>> LoadItems()
Returns
Type |
Description |
Task<IEnumerable<T>> |
The list of loaded entities to be displayed in the tree view
|
OnDeleteItem(T)
Declaration
protected virtual void OnDeleteItem(T newItem)
Parameters
Type |
Name |
Description |
T |
newItem |
The item being deleted from this treenode collection
|
OnNodeMoved(TreeNode<T>, TreeNode<T>, TreeNode<T>)
Called when a tree node has been moved to allow any modifications to the old/new parent and sub items of the moved tree node
Declaration
public virtual void OnNodeMoved(TreeNode<T> oldParent, TreeNode<T> newParent, TreeNode<T> movedItem)
Parameters
Type |
Name |
Description |
TreeNode<T> |
oldParent |
The old parent of this tree node
|
TreeNode<T> |
newParent |
The new parent for this tree node
|
TreeNode<T> |
movedItem |
The tree node that was mvoed
|
OnSelectionChanged(object, EventArgs)
Declaration
protected void OnSelectionChanged(object sender, EventArgs e)
Parameters
OpenItem(T)
Declaration
public virtual Task OpenItem(T item)
Parameters
Type |
Name |
Description |
T |
item |
The item in the tree view to open
|
Returns
Type |
Description |
Task |
A task indicating the completion of the operation
|
PromptForItemLabel(T)
Declaration
public virtual Task PromptForItemLabel(T item)
Parameters
Type |
Name |
Description |
T |
item |
|
Returns
SetSearch(string, IEnumerable<string>)
Declaration
public void SetSearch(string search, IEnumerable<string> columns)
Parameters
ToggleSearch(bool)
Declaration
public void ToggleSearch(bool visible)
Parameters
Type |
Name |
Description |
bool |
visible |
|
UpdateNewItem(T)
Updates the newly created item to be a child of the currently selected tree node in the TreeView if
there is a current treenode selected
Declaration
protected virtual Task UpdateNewItem(T newItem)
Parameters
Type |
Name |
Description |
T |
newItem |
The new item to be updated as being a child of the currently selected tree node in the tree view
|
Returns
UpdateRootCopiedNode(TreeNode<T>, TreeNode<T>)
Declaration
protected virtual Task UpdateRootCopiedNode(TreeNode<T> original, TreeNode<T> item)
Parameters
Returns
WrapAsTreeNodes(TreeNode<T>, IEnumerable<T>)
Declaration
public IEnumerable<TreeNode<T>> WrapAsTreeNodes(TreeNode<T> parent, IEnumerable<T> allItems)
Parameters
Returns
WrapAsTreeNodes(IEnumerable<T>)
The method used by DisplayUI() to enumerate all the items to be displayed in the tree view and wrap
them in a TreeNode<T>
Determines the root tree node entities while doing so
Declaration
protected virtual IEnumerable<TreeNode<T>> WrapAsTreeNodes(IEnumerable<T> items)
Parameters
Type |
Name |
Description |
IEnumerable<T> |
items |
All the entities to be displayed in a tree view
|
Returns
Type |
Description |
IEnumerable<TreeNode<T>> |
The collection of root (top level) tree nodes with no parent, that in turn contain all the other items in the
tree view as their children
|
Implements
Extension Methods