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 pathfilter-menu.tsx
More file actions
72 lines (68 loc) · 4.13 KB
/
filter-menu.tsx
File metadata and controls
72 lines (68 loc) · 4.13 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
65
66
67
68
69
70
71
72
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { DropDownListComponent, ChangeEventArgs } from '@syncfusion/ej2-react-dropdowns';
import { GridComponent, ColumnsDirective, ColumnDirective, Page, Filter, Inject, FilterType } from '@syncfusion/ej2-react-grids';
import { orderDataSource } from './data';
import { SampleBase } from '../common/sample-base';
export class FilterMenu extends SampleBase<{}, {}> {
private gridInstance: GridComponent;
private filterType: { [key: string]: Object }[] = [
{ text: 'Menu', value: 'Menu' },
{ text: 'Checkbox', value: 'CheckBox' },
{ text: 'Excel', value: 'Excel' },
];
public filterSettings: any = { type: 'Menu' }
private fields: Object = { text: 'text', value: 'value' };
public format: any = {type:'datetime',format:'M/d/y hh:mm a'};
public onChange(sel: { itemData: { text: string, value: string } }): void {
this.gridInstance.filterSettings.type = sel.itemData.value as FilterType;
this.gridInstance.clearFiltering();
}
render() {
return (
<div className='control-pane'>
<div className='control-section row'>
<div style={{ padding: '14px' }}>
<DropDownListComponent id="ddlelement" dataSource={this.filterType} fields={this.fields} change={this.onChange.bind(this)} index={0} popupHeight="150px" width="200px" />
</div>
<GridComponent dataSource={orderDataSource} allowPaging={true} ref={grid => this.gridInstance = grid} pageSettings={{ pageSize: 10, pageCount: 5 }} allowFiltering={true} filterSettings={this.filterSettings}>
<ColumnsDirective>
<ColumnDirective field='OrderID' headerText='Order ID' width='120' textAlign='Right'></ColumnDirective>
<ColumnDirective field='CustomerName' headerText='Customer Name' width='150'></ColumnDirective>
<ColumnDirective field='OrderDate' headerText='Order Date' width='130' format={this.format} textAlign='Right' />
<ColumnDirective field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right' />
<ColumnDirective field='ShipCountry' headerText='Ship Country' width='150'></ColumnDirective>
</ColumnsDirective>
<Inject services={[Filter, Page]} />
</GridComponent>
</div>
<div id="action-description">
<p>
This sample demonstrates the way of filtering Grid columns using menu, checkbox and excel filter UI. In this sample,
click the filtering icon from column header to show filter UI for a particular column. You can change
the filter type from the dropdown.
</p>
</div>
<div id='description'>
<p>The filtering feature enables the user to view the reduced amount of records based on filter criteria.
It can be enabled by setting <code><a target='_blank' className='code'
href='http://ej2.syncfusion.com/react/documentation/grid/api-gridComponent.html#allowfiltering-boolean'>allowFiltering
</a></code> property as true.</p>
<p>Grid supports the following filter types. They are, </p>
<ul>
<li><code>FilterBar</code></li>
<li><code>Menu</code></li>
<li><code>CheckBox</code></li>
<li><code>Excel</code></li>
</ul>
<p>
you can enale the filter type by setting <code><a target='_blank' className='code'
href='http://ej2.syncfusion.com/documentation/grid/api-filterSettings.html?lang=typescript#type-string'>
filterSettings->type</a>
</code>
</p>
</div>
</div>
)
}
}