SortableStack
Description
SortableStack is a stack-based container whose child items can be reordered with drag and drop. It wraps a standard Stack internally, tracks a stable identifier for each item, and reports the updated ordering when the user finishes sorting.
Use it when the visual order matters and you need to persist or react to that order, such as dashboards, pinned lists, or configurable layouts.
Usage
Create a SortableStack through the SortableStack(...), VSortableStack(), or HSortableStack() helpers. Add items with stable identifiers, then listen for sorting changes.
SortableStackItem
Each draggable entry is represented by SortableStackItem.
Identifieris the unique key used for ordering.Componentis the rendered child component.
API reference
public class SortableStack : IComponent, IHasBackgroundColor, IHasMarginPadding, ISpecialCaseStyling, ICanWrapA Stack component that allows its children to be reordered via drag and drop.
Constructors
Properties
public string Background { get ; set ; }Gets or sets the background color.
public dom.HTMLElement StylingContainerGets the styling container.
public bool PropagateToStackItemParentGets whether styling should propagate to the stack item parent.
Methods
public void Add(string identifier, IComponent component)Adds a component to the sortable stack.
Parameters
- identifier
- A unique identifier for the component.
- component
- The component to add.
public void Add(SortableStackItem item)Adds a SortableStackItem to the stack.
Parameters
- item
- The item to add.
public SortableStack Children(params SortableStackItem[] children)Sets the children of the sortable stack.
Parameters
- children
- The children items.
Returns
The current instance of the type.
public dom.HTMLElement Render()Renders the sortable stack.
Returns
The rendered HTMLElement.
public SortableStack AlignItemsCenter()Aligns items in the center.
Returns
The current instance of the type.
public void LoadSorting(string[] itemOrder)Loads the sorting order of the items. Should be called after all items have been added.
Parameters
- itemOrder
- An array of identifiers in the desired order.
public void OnSortingChanged(Action<string[]> onSortingChanged)Adds a sorting change event handler.
Parameters
- onSortingChanged
- The event handler action.
public SortableStack NoWrap()Disables wrapping of items.
Returns
The current instance of the type.
public SortableStack Wrap()Enables wrapping of items.
Returns
The current instance of the type.
public SortableStack AlignItems(ItemAlign align)Sets the alignment of items.
Parameters
- align
- The alignment.
Returns
The current instance of the type.
public SortableStack Relative()Sets the stack to use relative positioning.
Returns
The current instance of the type.
public SortableStack AlignContent(ItemAlign align)Sets the content alignment.
Parameters
- align
- The alignment.
Returns
The current instance of the type.
public SortableStack JustifyContent(ItemJustify justify)Sets the content justification.
Parameters
- justify
- The justification.
Returns
The current instance of the type.
public SortableStack JustifyItems(ItemJustify justify)Sets the item justification.
Parameters
- justify
- The justification.
Returns
The current instance of the type.
public SortableStack RemovePropagation()Removes event propagation.
Returns
The current instance of the type.
public SortableStack OnMouseOver(ComponentEventHandler<Stack, Event> onMouseOver)Adds a mouse over event handler.
public SortableStack OnMouseOut(ComponentEventHandler<Stack, Event> onMouseOut)Adds a mouse out event handler.
public SortableStack NoDefaultMargin()Removes the default margin from the stack.
Returns
The current instance of the type.
public class SortableStackItemRepresents an item within a SortableStack.