The Accordion control represents a container of items, which can be expanded and collapsed. The AccordionItem control derives from WindowBase and represents a window with header and content. Only one of the items in the Accordion control can be expanded at a time.
Use the Items property to get a reference to the control's collection of AccordionItems.
Set the SelectedIndex property to expand the corresponding item. If the SelectedIndex is set to -1 all items will be collapsed.
Use Accordion.Items.Add method to add a new item to the collection.
C#
![]() |
---|
AccordionItem item = new AccordionItem(); |
VB.NET
![]() |
---|
Dim item As New AccordionItem() |
Use Accordion.Items.Remove or Accordion.Items.RemoveAt to remove a specified item from the collection.
C#
![]() |
---|
Accordion1.Items.Remove(Accordion1.Items[0]); |
VB.NET
![]() |
---|
Accordion1.Items.Remove(Accordion1.Items(0)) |
The following events are exposed by the Accordion control.
Event | Event arguments | Description |
---|---|---|
System.EventArgs | Raised when the value of the SelectedIndex property has changed. | |
Raised when a item is selected. | ||
Raised when a item is deselected. | ||
Raised when an AccordionItem is created. | ||
Raised when an AccordionItem is deleted. |
You can access the control on the client side by its ClientID.
JavaScript
![]() |
---|
var accordion = $find("Accordion1"); |
Use the getAllItems method to get a reference to the control's items array. Use the getActiveItem method to access the currently expanded item.
Use the selectItem method to expand the specified item.
JavaScript
![]() |
---|
accordion.selectItem(accordion.getAllItems()[0]); |
Use the Accordion.createItem method to add a new item to its items array. The createItem method accepts as parameter a JSON object, containing the data for the new item. Use the data object to define values for the properties and events, exposed by the AccordionItem class.
JavaScript
![]() |
---|
accordion.createItem({ properties: {title: "Client item"}, events: {headerClick: onItemHeaderClick} }); |
Use the Accordion.deleteItem method to remove a specified item from the array.
JavaScript
![]() |
---|
accordion.deleteItem(accordion.getActiveItem()); |
The following client-side events are exposed by the Accordion class.
Event | Event arguments | Script property | Description |
---|---|---|---|
- | Raised just after the control has finished loading and is ready for interaction. | ||
Raised when the expanded item in the Accordion control is about to be changed. | |||
Raised when the expanded item in the Accordion control has changed. |
The following client-side events are exposed by the AccordionItem class.
Event | Event arguments | Script property | Description |
---|---|---|---|
Raised when the user clicks the header of the control. | |||
- | Raised when the internal iframe has finished loading. | ||
- | Raised just after the control has finished loading and is ready for interaction. |