| Document | Author | Created Date | |
|---|---|---|---|
| {{ item.name }} | {{ item.author }} | {{ item.date | date }} |
The uxSelection directive can be used to allow items to easily be selected and
deselected. This is particularly useful in tables where rows can be selected to perform actions on
specific items. The uxSelection directive should be added to the container element,
for example a table.
Each selectable item should be a child element with the uxSelectionItem directive
applied to it.
Each selectable item will get a ux-selection-focused class applied when the item
receives keyboard focus and a ux-selection-selected class when the item becomes
selected. These can be used to customize the appearance of the items in their various states.
The following can be used to interact with and customize the behavior of the
uxSelection directive.
simple - This allows clicking on an item to toggle its selected state. It also
provides keyboard navigation using the arrow keys and toggling using the spacebar key.
row - This allows more complex selection behavior. Clicking on an item will
select only that item and deselect all others. Multiple items can be selected by
ctrl clicking on items, and groups of items can be selected by
shift clicking. Keyboard navigation is also provided using the arrow keys and
spacebar to toggle selection and ctrl and shift support is also
available for multiple selection.
row-alt - This is similar to row mode, except that the cursor keys
move the selection as well as the focus. Holding ctrl with the cursor keys
allows the focus to be moved without affecting the selection.
Alternatively, custom selection behavior can be defined by defining a class which extends
SelectionStrategy, and providing an instance of the custom class to this
property. See below for details of the SelectionStrategy class.
uxSelectionItems is not available, e.g. within a virtual scroll container.
uxSelectionItem
elements within the directive.
uxSelectionItem
elements within the directive.
The following can be used to interact with and customize the behavior of the
uxSelectionItem directive.
aria-selected
is added to the host element.
The SelectionStrategy class, which can be subclassed to provide custom selection
behavior, has the following interface:
data. Override this function to provide custom behavior.
data. Override this function to provide custom behavior.
data. Override this function to provide custom behavior.
The following code can be used to create the example above: