Group items in popup in Angular Split button component
27 Apr 20243 minutes to read
Grouped items are possible in SplitButton by templating entire popup with ListView. Check ListView grouping
and create such items. Create ListView with id listview
and provide element of the ListView as target of SplitButton to render it in popup area.
In this following example, ListView is created and its element is set as target
for SplitButton.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SplitButtonModule } from '@syncfusion/ej2-angular-splitbuttons'
import { ListViewModule } from '@syncfusion/ej2-angular-lists'
import { Component } from '@angular/core';
@Component({
imports: [
SplitButtonModule,
ListViewModule
],
standalone: true,
selector: 'app-root',
template: `<div class="e-section-control">
<!-- To render ListView. -->
<ejs-listview id='listview' [dataSource]='listItems' [fields]='field' sortOrder='Descending'></ejs-listview>
<!-- To render splitbutton. -->
<ejs-splitbutton content="ClipBoard" target='#listview'></ejs-splitbutton></div>`
})
export class AppComponent {
// Datasource for listview.
public listItems: { [key: string]: Object }[] = [
{
'text': 'Cut',
'category': 'Basic'
},
{
'text': 'Copy',
'category': 'Basic'
},
{
'text': 'Paste',
'category': 'Basic'
},
{
'text': 'Paste as Formula',
'category': 'Advanced'
},
{
'text': 'Paste as Hyperlink',
'category': 'Advanced'
},
];
public field: Object = { groupBy: 'category' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));