This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgrouping.tsx
More file actions
64 lines (63 loc) · 3.92 KB
/
grouping.tsx
File metadata and controls
64 lines (63 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { GridComponent, ColumnsDirective, ColumnDirective, Page, Group, Sort, Inject } from '@syncfusion/ej2-react-grids';
import { inventoryData } from './data';
import { SampleBase } from '../common/sample-base';
let refresh: Boolean;
export class Grouping extends SampleBase<{}, {}> {
public groupOptions: Object = { showGroupedColumn: false, columns: ['Country'] };
private gridInstance: GridComponent;
public dataBound() {
if(refresh) {
this.gridInstance.groupColumn('Country');
refresh = false;
}
}
public load() {
refresh = (this as any).refreshing;
}
render() {
return (
<div className='control-pane'>
<div className='control-section'>
<GridComponent dataSource={inventoryData} allowPaging={true} ref={ grid => this.gridInstance = grid} pageSettings={{ pageCount: 5 }} allowGrouping={true} groupSettings={this.groupOptions} allowSorting={true} height="320"
dataBound={this.dataBound.bind(this)} load={this.load}>
<ColumnsDirective>
<ColumnDirective field='Inventor' headerText='Inventor Name' width='180' ></ColumnDirective>
<ColumnDirective field='NumberofPatentFamilies' headerText='Number of Patent Families' width='220' textAlign='Right'></ColumnDirective>
<ColumnDirective field='Country' headerText='Country' width='140' />
<ColumnDirective field='Active' headerText='Active' width='120' />
<ColumnDirective field='Mainfieldsofinvention' headerText='Main fields of invention' width='200'></ColumnDirective>
</ColumnsDirective>
<Inject services={[Page, Group, Sort]} />
</GridComponent>
<div className="e-dsalign">Source:
<a href="https://en.wikipedia.org/wiki/List_of_prolific_inventors" target='_blank'>Wikipedia: List of Prolific inventors</a>
</div>
</div>
<div id="action-description">
<p>This sample demonstrates grouping feature of the Grid component. In this sample, the Grid data is grouped against
Country column. To group any other column simply drag the column header and drop on the group drop area.</p>
</div>
<div id='description'>
<p>The Grid control has options to group the records based on the required column. When grouping is applied, grouped
records are organized into a hierarchical structure to facilitate easier expansion and collapse of records. To enable
grouping, set <code><a target='_blank' className='code'
href="http://ej2.syncfusion.com/react/documentation/grid/api-gridComponent.html#allowgrouping-boolean">
allowGrouping</a></code> property as true.</p>
<p>Columns can be grouped by simply dragging the column header and drop on the group drop area.</p>
<p>In this demo, to group a specify column, drag and drop the column in the group drop area.</p>
<p style={{ fontWeight: 500 }}>Injecting Module:</p>
<p>
Grid component features are segregated into individual feature-wise modules. To use grouping feature, we need to inject
<code>Group</code> module into the <code>services</code>.
</p>
<p>
More information on the grouping feature configuration can be found in this
<a target="_blank" href="http://ej2.syncfusion.com/react/documentation/grid/api-gridComponent.html#groupsettings-groupsettingsmodel"> documentation section</a>.
</p>
</div>
</div>
)
}
}