new UWA.Controls.Segmented(options)
Display a horizontally stacked list of items
Available Events
Event | Description |
---|---|
onPreInject |
Triggered before inject |
onPostInject |
Triggered after inject |
onResize |
Invoked when control needs to resize |
onClick |
Invoked when an item is clicked |
onChange |
Invoked when an item state change |
Example
var myControl = new UWA.Controls.Segmented({
data: {
option_a: {text: 'a'},
option_bb: {text: 'bb'},
option_ccc: {text: 'ccc'},
option_dddd: {text: 'dddd'}
}
});
myControl.inject(myControlContainer);s
// OR
myControlContainer.appendChild(myControl.getContent());
Parameters
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Options hash or a option/value pair. Properties
|
Extends
- UWA.Controls.Abstract
Index
Members
Methods
Members
-
itemLength :Number
-
The items length.
Type
- Number
Methods
-
buildSkeleton()
-
Build main dom elements
-
updateItemClassNames()
-
Recompute items classnames, with item-first and item-last classes (called each time an item is added)
-
createItem(name, itemConfig) → {HTMLElement}
-
Build an item HTMLelement and add event
Parameters
Name Type Description name
String Internal item Id
itemConfig
Object Item configuration
Returns
- Type
- HTMLElement
-
onResize()
-
Resize all items if needed (this.options.constantItemWidth)
-
onClick()
-
Invoked when an item is clicked
-
addItems(items)
-
Add some items to the control
Parameters
Name Type Description items
Object Items to be added
-
addItem(name, itemConfig)
-
Add one item at the end of the control
Parameters
Name Type Description name
String Internal item Id
itemConfig
Object Item configuration
-
setItemTitle(itemName, newTitle)
-
Change an item title.
Parameters
Name Type Description itemName
String Internal item Id
newTitle
String New title
-
setItemState(name, state, notify)
-
Open or Close an item.
Parameters
Name Type Argument Default Description name
String Internal item Id
state
Boolean Select/unselect item
notify
Boolean <optional>
true Should trigger onChange or not
-
toggleItem(name, notify)
-
Toggle item state.
Parameters
Name Type Argument Default Description name
String internal item Id
notify
Boolean <optional>
true should trigger onChange or not
-
unselectItem(name, notify)
-
Unselect an item.
Parameters
Name Type Argument Default Description name
String internal item Id
notify
Boolean <optional>
true should trigger onChange or not
-
selectItem(name, notify)
-
Select an item.
Parameters
Name Type Argument Default Description name
String internal item Id
notify
Boolean <optional>
true should trigger onChange or not
-
getSelectedItems() → {Array}
-
Get all selected items.
Returns
an array with all currently selected IDs
- Type
- Array
-
isSelected(name)
-
Return an element state
Parameters
Name Type Description name
String Internal item Id
-
unselectItems(notify, exceptedItemName)
-
Unselect all items
Parameters
Name Type Argument Default Description notify
Object <optional>
false Notify or not
exceptedItemName
String You can unselect all except one item, if neeeded