JavaScript/jQuery List - Expand and Collapse a Group
If the user should be able to collapse or expand a group in the List, set the collapsibleGroups property to true. In this case, the user can collapse or expand a group with a click on the group header.
JavaScript
- const fruitsVegetables = [{
- key: "Fruits",
- items: [
- { name: "Apples", count: 10 },
- { name: "Oranges", count: 12 },
- { name: "Lemons", count: 15 }
- ]
- }, {
- // ...
- }];
- $(function() {
- $("#listContainer").dxList({
- dataSource: fruitsVegetables,
- grouped: true,
- collapsibleGroups: true
- });
- });
To collapse or expand a specific group programmatically, call the collapseGroup(groupIndex) or expandGroup(groupIndex) method.
JavaScript
- const list = $("#listContainer").dxList("instance");
- list.collapseGroup(0); // collapses the group with index 0
- list.expandGroup(4); // expands the group with index 4