Usage
Signature:
interface CListViewElement<K extends string | number,D>
Typescript Import Format
//To typecheck the element APIs, import as below.
import { CListViewElement } from "oj-c/list-view";
//For the transpiled javascript to load the element's module, import as below
import "oj-c/list-view";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Slots
JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.
-
itemTemplate
-
The
itemTemplate
slot is used to specify the template for rendering each item in the List. The slot content must be a <template> element.When the template is executed for each item, it will have access to the binding context containing the following properties:
- $current - an object that contains information for the current item.
Properties of $current:
Name Type Description data
D The data of the item. Note this is made available primarily to ease migration. Applications should get the data from the item property instead. isTabbable
boolean A boolean indicating whether the item is in tabbable mode or not. Template elements should not be tab-stops when the item is not in tabbable mode, this context can be used to implement conditional behavior for all tabbable child elements. item
Item.<K, D> Contains the data and metadata of the item. -
noData
-
The
noData
slot is used to specify the content to display when the list is empty. The slot content must be a <template> element. If not specified then a default no data message will be displayed.
Attributes
-
context-menu-config :oj-c.ListView.ContextMenuConfig.<K, D>
-
Specifies a context menu configuration. It takes the keys `accessibleLabel` and `items`, where `accessibleLabel` is optional and items required . `items` function returns an array of menu item object representations that indicates what menu items are going to be part of menu based on some specific context menu context.
Context Menu Item Type Def ContextMenuSeparator { type: 'separator'} MenuItem { type?: 'item'; label: string; key: string; disabled?: boolean; onAction?: () => void; startIcon?: MenuIcon; endIcon?: MenuIcon; variant?: 'standard' | 'destructive'; }; ContextMenuSubMenu { type: 'submenu'; label?: string; disabled?: boolean; startIcon?: string; items?: Array<ContextMenuItems>; }; ContextMenuSelectSingle { type: 'selectsingle'; key?: string; items?: Array<MenuSelectItem>; selection?: string; onSelection?: (detail: { value: string }) => void; }; ContextMenuSelectMultiple { type: 'selectmultiple'; key?: string; items?: Array<MenuSelectItem>; selection?: Array<string>; onSelection?: (detail: { value: Array<string> }) => void; }; MenuIcon { type?: 'class'; class: string; } | { type: 'img'; src: string; }; MenuSelectItem { label: string; disabled?: boolean; endIcon?: MenuIcon; value: string; } Names
Item Name Property contextMenuConfig
Property change event contextMenuConfigChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-context-menu-config-changed
-
(readonly) current-item :K
-
The item that currently has keyboard focus
- Supports writeback:
true
Names
Item Name Property currentItem
Property change event currentItemChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-current-item-changed
-
data :(DataProvider.<K, D>|null)
-
The data source for ListView. Must be of type DataProvider.
Names
Item Name Property data
Property change event dataChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-data-changed
-
gridlines :oj-c.ListView.Gridlines
-
Specifies whether the horizontal grid lines should be visible. By default gridlines are hidden. It takes the keys `item`, `top` and `bottom`, each of which are optional and take a value of "hidden" or "visible". `item` toggles the presence of bottom gridlines except the last item, and `top` and `bottom` toggle the initial and trailing gridlines. By default all gridlines are hidden.
Names
Item Name Property gridlines
Property change event gridlinesChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-gridlines-changed
-
reorderable :{ items?: 'enabled' | 'disabled' }
-
The reorder option contains a subset of options for reordering items.
The following options are supported:
- items: Enable or disable reordering the items within the same ListView using drag and drop or keyboard. Specify 'enabled' to enable reordering. Setting the value to
"disabled"
or setting the"reorderable"
property tonull
(or omitting it), disables reordering support.
Names
Item Name Property reorderable
Property change event reorderableChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-reorderable-changed
- items: Enable or disable reordering the items within the same ListView using drag and drop or keyboard. Specify 'enabled' to enable reordering. Setting the value to
-
reorderable.items :"disabled"|"enabled"
-
- Default Value:
"disabled"
Names
Item Name Property reorderable.items
-
scroll-policy-options :{ fetchSize?: number; scroller?: string }
-
scrollPolicy options.
The following options are supported:
- fetchSize: The number of items fetched each time when scroll to the end.
- scroller: The css selector that locates the element in which listview uses to determine the scroll position as well as the maximum scroll position where scroll to the end will trigger a fetch. If not specified then the root element of listview is used.
Names
Item Name Property scrollPolicyOptions
Property change event scrollPolicyOptionsChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-scroll-policy-options-changed
-
scroll-policy-options.fetch-size :number
-
Names
Item Name Property scrollPolicyOptions.fetchSize
-
scroll-policy-options.scroller :string
-
Names
Item Name Property scrollPolicyOptions.scroller
-
selected :ImmutableKeySet.<K>
-
The current selected items in the ListView. An empty KeySet indicates nothing is selected. Note that property change event for the deprecated selection property will still be fire when selected property has changed. In addition, AllKeySetImpl set can be used to represent select all state. In this case, the value for selection would have an 'inverted' property set to true, and would contain the keys of the items that are not selected.
- Supports writeback:
true
Names
Item Name Property selected
Property change event selectedChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-selected-changed
-
selection-mode :"multiple"|"none"|"single"|"singleRequired"
-
The type of selection behavior that is enabled on the ListView. This attribute controls the number of selections that can be made via selection gestures at any given time.
If
single
ormultiple
is specified, selection gestures will be enabled, and the ListView's selection styling will be applied to all items specified by the selected attribute. IfsingleRequired
is specified, then the behavior is the same as single except that ListView will ensure there is an item selected at all time. Specifically, user will not be able to de-selected a selected item. And if selection is initially empty, ListView will select the first item. Ifnone
is specified, selection gestures will be disabled, and the ListView's selection styling will not be applied to any items specified by the selected attribute.Changing the value of this attribute will not affect the value of the selected attribute.
- Default Value:
"none"
Supported Values:
Value Description multiple
Multiple items can be selected at the same time. none
Selection is disabled. single
Only a single item can be selected at a time. singleRequired
Only a single item can be selected at a time. In addition, ListView will also ensure that an item is selected at all time. Names
Item Name Property selectionMode
Property change event selectionModeChanged
Property change listener attribute (must be of type function, see Events and Listeners for additional information.) on-selection-mode-changed
Events
-
ojContextMenuAction
-
Triggered when a menu item is clicked, whether by keyboard, mouse, or touch events.
Properties:
All of the event payloads listed below can be found under
event.detail
. See Events and Listeners for additional information.Name Type contextMenuContext
oj-c.ListView.ListItemContextProps.<K, D> menuItemKey
string -
ojContextMenuSelection
-
Triggered when a select menu item is clicked, whether by keyboard, mouse, or touch events.
Properties:
All of the event payloads listed below can be found under
event.detail
. See Events and Listeners for additional information.Name Type contextMenuContext
oj-c.ListView.ListItemContextProps.<K, D> menuSelectionGroupKey
string value
string|Array<string> -
ojFirstSelectedItem
-
Triggered when data for the first selected item is available. This can occurred when:
- ListView is initialized with a selection or first item is selected due to singleRequired selection mode.
- Selection has changed.
- Data for the first selected item is updated.
singleRequired
.Properties:
All of the event payloads listed below can be found under
event.detail
. See Events and Listeners for additional information.Name Type data
D key
K -
ojItemAction
-
Triggered when user performs an action gesture on an item while ListView is in navigation mode. The action gestures include:
- User clicks anywhere in an item
- User taps anywhere in an item
- User pressed spacebar on an item
Properties:
All of the event payloads listed below can be found under
event.detail
. See Events and Listeners for additional information.Name Type context
oj-c.ListView.ListItemContextProps.<K, D> -
ojReorder
-
Triggered after items are reordered within ListView via drag and drop or keyboard.
Properties:
All of the event payloads listed below can be found under
event.detail
. See Events and Listeners for additional information.Name Type Description itemKeys
Array<K> An array of keys of the items that are moved referenceKey
K | null The key of the item where the moved items will be dropped after. If the moved items were dropped at the very beginning, the referenceKey will be null. reorderedKeys
Array<K> An array of keys matching the new order of items
Methods
-
getProperty(property) : {any}
-
Retrieves the value of a property or a subproperty.
Parameters:
Name Type Description property
The property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description properties
An object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a corresponding event.
Parameters:
Name Type Description property
The property name to set. Supports dot notation for subproperty access. value
The new value to set the property to. Returns:
- Type
- void
Type Definitions
-
ContextMenuConfig<K,D>
-
Properties:
Name Type Argument accessibleLabel
string <optional>
items
(context: oj-c.ListView.ListItemContextProps<K, D>) => ContextMenuItems[] -
Gridlines
-
Properties:
Name Type Argument bottom
"hidden" | "visible" <optional>
item
"hidden" | "visible" <optional>
top
"hidden" | "visible" <optional>
-
ListItemContextProps<K,D>
-
Properties:
Name Type Description data
D The data of the item. Note this is made available primarily to ease migration. Applications should get the data from the item property instead. item
Item.<K, D> Contains the data and metadata of the item.