- Index
- »
- fan.pi
- »
- ItemSelection
ItemSelection
@Js
class ItemSelection : Obj
ItemSelection provides APIs to work with selected Items.
Get or set single selection by Item.data
Get or set multiple selection by Item.data
Get or set single selection by Item.id
Get or set multiple selection by Item.id
Get or set single selection by Item
Get or set multiple selection by Item
Max entries to retain, or zero for unlimited
Most-recently-used ordering
Add item to the selection
Is this item eligible to be selected
Clear the selection
Is the given item currently selected (keyed by id)
Return if selection should be enabled for given select mode
Is the current selection empty
Return if size is one
Return if size is one or more
Remove item from the selection by id (no-op if not present)
Return number of selected items
Toggle item in the selection
Void add(Item item)
Add item to the selection. In mru mode the item moves to the front and re-adding an existing item refreshes its recency; otherwise it is appended to the end. Overflow past max evicts the oldest. No-op in append mode if already present. Respects mode (single replaces, disabled is a no-op).
virtual Bool canSelect(Item item)
Is this item eligible to be selected. Advisory for UI enablement; does not gate add. Anything selected can always be removed, so there is no corresponding removal predicate.
Void clear()
Clear the selection
Bool contains(Item item)
Is the given item currently selected (keyed by id)
Obj? : data
Get or set single selection by Item.data
Obj[] : dataList
Get or set multiple selection by Item.data
Bool enabled(SelectMode mode)
Return if selection should be enabled for given select mode
Obj? : id
Get or set single selection by Item.id
Ref[] : ids
Get or set multiple selection by Item.id
Bool isEmpty()
Is the current selection empty
Item? : item
Get or set single selection by Item
Item[] : items
Get or set multiple selection by Item
Int : max
Max entries to retain, or zero for unlimited. Overflow evicts the oldest.
Bool : mru
Most-recently-used ordering: add pushes to the front and re-adding an existing item refreshes its recency. Default appends to the end.
Bool one()
Return if size is one
Bool oneOrMore()
Return if size is one or more
Void remove(Item item)
Remove item from the selection by id (no-op if not present)
Int size()
Return number of selected items
Void toggle(Item item)
Toggle item in the selection