Items in popup can be grouped in SplitButton by templating entire popup with ListView. To achieve grouping in ListView, check ListView grouping
documentation. To template ListView in popup, create ListView with id listview
and provide it as
target
for SplitButton.
The following example illustrates how to group items in popup using ListView component.
import { enableRipple } from '@syncfusion/ej2-base';
import { SplitButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import { ListViewComponent } from '@syncfusion/ej2-react-lists';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
// To render SplitButton.
class App extends React.Component<{}, {}> {
// Datasource for listview.
public listItems: Array<{ [key: string]: string; }> = [
{
'category': 'Basic',
'text': 'Cut'
},
{
'category': 'Basic',
'text': 'Copy',
},
{
'category': 'Basic',
'text': 'Paste'
},
{
'category': 'Advanced',
'text': 'Paste as Formula'
},
{
'category': 'Advanced',
'text': 'Paste as Hyperlink'
},
];
public field: any = { groupBy: 'category' };
public render() {
return (
<div>
<ListViewComponent id="listview" dataSource={this.listItems} fields={this.field} sortOrder="Descending"/>
<SplitButtonComponent target="#listview">ClipBoard</SplitButtonComponent>
</div>
);
}
}
ReactDom.render(<App />,document.getElementById('button'));
<!DOCTYPE html>
<html lang="en">
<head>
<title>Syncfusion React SplitButton</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for React Components" />
<meta name="author" content="Syncfusion" />
<link href="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
<link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet" />
<link href="//cdn.syncfusion.com/ej2/ej2-popups/styles/material.css" rel="stylesheet" />
<link href="//cdn.syncfusion.com/ej2/ej2-splitbuttons/styles/material.css" rel="stylesheet" />
<link href="//cdn.syncfusion.com/ej2/ej2-lists/styles/material.css" rel="stylesheet" />
<link href="style.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='button'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
import { enableRipple } from '@syncfusion/ej2-base';
import { SplitButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import { ListViewComponent } from '@syncfusion/ej2-react-lists';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
// To render SplitButton.
class App extends React.Component {
constructor() {
super(...arguments);
// Datasource for listview.
this.listItems = [
{
'category': 'Basic',
'text': 'Cut'
},
{
'category': 'Basic',
'text': 'Copy',
},
{
'category': 'Basic',
'text': 'Paste'
},
{
'category': 'Advanced',
'text': 'Paste as Formula'
},
{
'category': 'Advanced',
'text': 'Paste as Hyperlink'
},
];
this.field = { groupBy: 'category' };
}
render() {
return (<div>
<ListViewComponent id="listview" dataSource={this.listItems} fields={this.field} sortOrder="Descending"/>
<SplitButtonComponent target="#listview">ClipBoard</SplitButtonComponent>
</div>);
}
}
ReactDom.render(<App />, document.getElementById('button'));