Filtering in React Multi select component
13 Dec 202324 minutes to read
The MultiSelect has built-in support to filter data items when allowFiltering
is enabled. The filter operation starts as soon as you start typing characters in the MultiSelect input.
To display filtered items in the popup, filter the required data and return it to the MultiSelect
via updateData method by using the filtering event.
The following sample illustrates how to query the data source and pass the data to the MultiSelect through the updateData
method in filtering
event.
[Class-component]
// import DataManager related classes
import { Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component {
// define the filtering data
searchData = [
{ index: "s1", country: "Alaska" }, { index: "s2", country: "California" },
{ index: "s3", country: "Florida" }, { index: "s4", country: "Georgia" }
];
// maps the appropriate column to fields property
fields = { text: "country", value: "index" };
constructor(props) {
super(props);
this.onFiltering = this.onFiltering.bind(this);
}
// filtering event handler to filter a country
onFiltering(args) {
let query = new Query();
// frame the query based on search string with filter type.
query = (args.text !== "") ? query.where("country", "startswith", args.text, true) : query;
// pass the filter data source, filter query to updateData method.
args.updateData(this.searchData, query);
}
render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" popupHeight="250px" fields={this.fields} filtering={this.onFiltering} allowFiltering={true} dataSource={this.searchData} placeholder="Select a country"/>);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
// import DataManager related classes
import { Query } from '@syncfusion/ej2-data';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component<{}, {}> {
// define the filtering data
private searchData: { [key: string]: Object }[] = [
{ index: "s1", country: "Alaska" }, { index: "s2", country: "California" },
{ index: "s3", country: "Florida" }, { index: "s4", country: "Georgia" }
];
// maps the appropriate column to fields property
private fields: object = { text: "country", value: "index" };
constructor(props: any) {
super(props);
this.onFiltering = this.onFiltering.bind(this);
}
// filtering event handler to filter a country
public onFiltering(args: FilteringEventArgs) {
let query = new Query();
// frame the query based on search string with filter type.
query = (args.text !== "") ? query.where("country", "startswith", args.text, true) : query;
// pass the filter data source, filter query to updateData method.
args.updateData(this.searchData, query);
}
public render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" popupHeight="250px" fields={this.fields} filtering={this.onFiltering} allowFiltering={true} dataSource={this.searchData} placeholder="Select a country" />
);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
[Functional-component]
// import DataManager related classes
import { Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// define the filtering data
const searchData = [
{ index: "s1", country: "Alaska" }, { index: "s2", country: "California" },
{ index: "s3", country: "Florida" }, { index: "s4", country: "Georgia" }
];
// maps the appropriate column to fields property
const fields = { text: "country", value: "index" };
// filtering event handler to filter a country
function onFiltering(args) {
let query = new Query();
// frame the query based on search string with filter type.
query = (args.text !== "") ? query.where("country", "startswith", args.text, true) : query;
// pass the filter data source, filter query to updateData method.
args.updateData(this.searchData, query);
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" popupHeight="250px" fields={fields} filtering={onFiltering} allowFiltering={true} dataSource={searchData} placeholder="Select a country"/>);
}
ReactDOM.render(<App />, document.getElementById('sample'));
// import DataManager related classes
import { Query } from '@syncfusion/ej2-data';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App(){
// define the filtering data
const searchData: { [key: string]: Object }[] = [
{ index: "s1", country: "Alaska" }, { index: "s2", country: "California" },
{ index: "s3", country: "Florida" }, { index: "s4", country: "Georgia" }
];
// maps the appropriate column to fields property
const fields: object = { text: "country", value: "index" };
// filtering event handler to filter a country
function onFiltering(args: FilteringEventArgs) {
let query = new Query();
// frame the query based on search string with filter type.
query = (args.text !== "") ? query.where("country", "startswith", args.text, true) : query;
// pass the filter data source, filter query to updateData method.
args.updateData(this.searchData, query);
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" popupHeight="250px" fields={fields} filtering={onFiltering} allowFiltering={true} dataSource={searchData} placeholder="Select a country" />
);
}
ReactDOM.render(<App />, document.getElementById('sample'));
Limit the minimum filter character
When filtering the list items, you can set the limit for character count to raise remote request and fetch filtered data on the MultiSelect. This can be done by manual validation within the filter event handler.
In the following example, the remote request does not fetch the search data until the search key contains three characters.
[Class-component]
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component {
// bind the DataManager instance to dataSource property
searchData = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
fields = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
sortOrder = 'Ascending';
constructor(props) {
super(props);
this.onFiltering = this.onFiltering.bind(this);
}
// filtering event handler to filter a customer
onFiltering(e) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
}
else {
// restrict the remote request until search key contains 3 characters.
if (e.text.length < 3) {
return;
}
let query = new Query().select(['ContactName', 'CustomerID']);
query = (e.text !== '') ? query.where('ContactName', 'startswith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={this.onFiltering} sortOrder={this.sortOrder} query={this.query} dataSource={this.searchData} fields={this.fields} placeholder="Select a customer"/>);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { SortOrder } from '@syncfusion/ej2-lists';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component<{}, {}> {
// bind the DataManager instance to dataSource property
private searchData: DataManager = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
private fields: object = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
private query: Query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
private sortOrder: SortOrder = 'Ascending';
constructor(props: any) {
super(props);
this.onFiltering = this.onFiltering.bind(this);
}
// filtering event handler to filter a customer
public onFiltering(e: FilteringEventArgs) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
} else {
// restrict the remote request until search key contains 3 characters.
if (e.text.length < 3) { return; }
let query: Query = new Query().select(['ContactName', 'CustomerID']);
query = (e.text !== '') ? query.where('ContactName', 'startswith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
public render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={this.onFiltering} sortOrder={this.sortOrder} query={this.query} dataSource={this.searchData} fields={this.fields} placeholder="Select a customer" />
);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
[Functional-component]
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// bind the DataManager instance to dataSource property
const searchData = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
const fields = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
const query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
const sortOrder = 'Ascending';
// filtering event handler to filter a customer
function onFiltering(e) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
}
else {
// restrict the remote request until search key contains 3 characters.
if (e.text.length < 3) {
return;
}
let query = new Query().select(['ContactName', 'CustomerID']);
query = (e.text !== '') ? query.where('ContactName', 'startswith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={onFiltering} sortOrder={sortOrder} query={query} dataSource={searchData} fields={fields} placeholder="Select a customer"/>);
}
ReactDOM.render(<App />, document.getElementById('sample'));
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { SortOrder } from '@syncfusion/ej2-lists';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// bind the DataManager instance to dataSource property
const searchData: DataManager = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
const fields: object = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
const query: Query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
const sortOrder: SortOrder = 'Ascending';
// filtering event handler to filter a customer
function onFiltering(e: FilteringEventArgs) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
} else {
// restrict the remote request until search key contains 3 characters.
if (e.text.length < 3) { return; }
let query: Query = new Query().select(['ContactName', 'CustomerID']);
query = (e.text !== '') ? query.where('ContactName', 'startswith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={onFiltering} sortOrder={sortOrder} query={query} dataSource={searchData} fields={fields} placeholder="Select a customer" />
);
}
ReactDOM.render(<App />, document.getElementById('sample'));
Change the filter type
While filtering, you can change the filter type to contains
, startsWith
, or endsWith
for string type within the filter event handler.
In the following examples, data filtering is done with endsWith
type.
[Class-component]
// import DataManager related classes
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component {
// bind the DataManager instance to dataSource property
searchData = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
fields = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
sortOrder = 'Ascending';
constructor(props) {
super(props);
this.onFiltering = this.onFiltering.bind(this);
}
// filtering event handler to filter a customer
onFiltering(e) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
}
else {
let query = new Query().select(["ContactName", "CustomerID"]);
// change the type of filtering
query = (e.text !== '') ? query.where('ContactName', 'endsWith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={this.onFiltering} query={this.query} sortOrder={this.sortOrder} dataSource={this.searchData} fields={this.fields} placeholder="Select a customer"/>);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
// import DataManager related classes
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { SortOrder } from '@syncfusion/ej2-lists';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component<{}, {}> {
// bind the DataManager instance to dataSource property
private searchData: DataManager = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
private fields: object = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
private query: Query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
private sortOrder: SortOrder = 'Ascending';
constructor(props: any) {
super(props);
this.onFiltering = this.onFiltering.bind(this);
}
// filtering event handler to filter a customer
public onFiltering(e: FilteringEventArgs) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
} else {
let query: Query = new Query().select(["ContactName", "CustomerID"]);
// change the type of filtering
query = (e.text !== '') ? query.where('ContactName', 'endsWith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
public render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={this.onFiltering} query={this.query} sortOrder={this.sortOrder} dataSource={this.searchData} fields={this.fields} placeholder="Select a customer" />
);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
[Functional-component]
// import DataManager related classes
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// bind the DataManager instance to dataSource property
const searchData = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
const fields = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
const query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
const sortOrder = 'Ascending';
// filtering event handler to filter a customer
function onFiltering(e) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
}
else {
let query = new Query().select(["ContactName", "CustomerID"]);
// change the type of filtering
query = (e.text !== '') ? query.where('ContactName', 'endsWith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={onFiltering} query={query} sortOrder={sortOrder} dataSource={searchData} fields={fields} placeholder="Select a customer"/>);
}
ReactDOM.render(<App />, document.getElementById('sample'));
// import DataManager related classes
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
import { SortOrder } from '@syncfusion/ej2-lists';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// bind the DataManager instance to dataSource property
const searchData: DataManager = new DataManager({
adaptor: new ODataV4Adaptor,
crossDomain: true,
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers'
});
// maps the appropriate column to fields property
const fields: object = { text: 'ContactName', value: 'CustomerID' };
// bind the Query instance to query property
const query: Query = new Query().select(['ContactName', 'CustomerID']).take(7);
// sort the resulted items
const sortOrder: SortOrder = 'Ascending';
// filtering event handler to filter a customer
function onFiltering(e: FilteringEventArgs) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.searchData);
} else {
let query: Query = new Query().select(["ContactName", "CustomerID"]);
// change the type of filtering
query = (e.text !== '') ? query.where('ContactName', 'endsWith', e.text, true) : query;
e.updateData(this.searchData, query);
}
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" allowFiltering={true} popupHeight="250px" filtering={onFiltering} query={query} sortOrder={sortOrder} dataSource={searchData} fields={fields} placeholder="Select a customer" />
);
}
ReactDOM.render(<App />, document.getElementById('sample'));
Case sensitive filtering
Data items can be filtered either with or without case sensitivity using the DataManager. This can be done by passing the fourth optional parameter of the where
clause.
The following example shows how to perform case-sensitive filter.
[Class-component]
import { Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component {
// define the JSON of data
sportsData = [
{ id: 'game1', sports: 'Badminton' },
{ id: 'game2', sports: 'Tennis' },
{ id: 'game3', sports: 'Football' }
];
// maps the appropriate column to fields property
fields = { text: 'sports', value: 'id' };
// sort the resulted items
sortOrder = 'Ascending';
// filtering event handler to filter a customer
onFiltering = (e) => {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.sportsData);
}
else {
let query = new Query().select(["sports", "id"]);
// enable the case sensitive filtering by passing false to 4th parameter.
query = (e.text !== '') ? query.where('sports', 'startsWith', e.text, false) : query;
e.updateData(this.sportsData, query);
}
};
render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" dataSource={this.sportsData} fields={this.fields} placeholder="Select a game" allowFiltering={true} filtering={this.onFiltering = this.onFiltering.bind(this)} sortOrder={this.sortOrder}/>);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
import { Query } from '@syncfusion/ej2-data';
import { SortOrder } from '@syncfusion/ej2-lists';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component<{}, {}> {
// define the JSON of data
private sportsData: { [key: string]: Object }[] = [
{ id: 'game1', sports: 'Badminton' },
{ id: 'game2', sports: 'Tennis' },
{ id: 'game3', sports: 'Football' }
];
// maps the appropriate column to fields property
private fields: object = { text: 'sports', value: 'id' };
// sort the resulted items
private sortOrder: SortOrder = 'Ascending';
// filtering event handler to filter a customer
public onFiltering = (e: FilteringEventArgs) => {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.sportsData);
} else {
let query: Query = new Query().select(["sports", "id"]);
// enable the case sensitive filtering by passing false to 4th parameter.
query = (e.text !== '') ? query.where('sports', 'startsWith', e.text, false) : query;
e.updateData(this.sportsData, query);
}
}
public render() {
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" dataSource={this.sportsData} fields={this.fields} placeholder="Select a game" allowFiltering={true} filtering={this.onFiltering = this.onFiltering.bind(this)} sortOrder={this.sortOrder} />
);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
[Functional-component]
import { Query } from '@syncfusion/ej2-data';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// define the JSON of data
const sportsData = [
{ id: 'game1', sports: 'Badminton' },
{ id: 'game2', sports: 'Tennis' },
{ id: 'game3', sports: 'Football' }
];
// maps the appropriate column to fields property
const fields = { text: 'sports', value: 'id' };
// sort the resulted items
const sortOrder = 'Ascending';
// filtering event handler to filter a customer
function onFiltering(e) {
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.sportsData);
}
else {
let query = new Query().select(["sports", "id"]);
// enable the case sensitive filtering by passing false to 4th parameter.
query = (e.text !== '') ? query.where('sports', 'startsWith', e.text, false) : query;
e.updateData(this.sportsData, query);
}
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" dataSource={sportsData} fields={fields} placeholder="Select a game" allowFiltering={true} filtering={onFiltering = onFiltering.bind(this)} sortOrder={sortOrder}/>);
}
ReactDOM.render(<App />, document.getElementById('sample'));
import { Query } from '@syncfusion/ej2-data';
import { SortOrder } from '@syncfusion/ej2-lists';
import { FilteringEventArgs, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// define the JSON of data
const sportsData: { [key: string]: Object }[] = [
{ id: 'game1', sports: 'Badminton' },
{ id: 'game2', sports: 'Tennis' },
{ id: 'game3', sports: 'Football' }
];
// maps the appropriate column to fields property
const fields: object = { text: 'sports', value: 'id' };
// sort the resulted items
const sortOrder: SortOrder = 'Ascending';
// filtering event handler to filter a customer
function onFiltering(e: FilteringEventArgs){
// load overall data when search key empty.
if (e.text === '') {
e.updateData(this.sportsData);
} else {
let query: Query = new Query().select(["sports", "id"]);
// enable the case sensitive filtering by passing false to 4th parameter.
query = (e.text !== '') ? query.where('sports', 'startsWith', e.text, false) : query;
e.updateData(this.sportsData, query);
}
}
return (
// specifies the tag for render the MultiSelect component
<MultiSelectComponent id="mtselement" dataSource={sportsData} fields={fields} placeholder="Select a game" allowFiltering={true} filtering={onFiltering = onFiltering.bind(this)} sortOrder={sortOrder} />
);
}
ReactDOM.render(<App />, document.getElementById('sample'));
Diacritics Filtering
MultiSelect supports diacritics filtering which will ignore the diacritics and makes it easier to filter the results in international characters lists when the ignoreAccent is enabled.
In the following sample,data with diacritics are bound as dataSource for MultiSelect.
[Class-compponent]
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component {
diacriticsData = [
'Aeróbics',
'Aeróbics en Agua',
'Aerografía',
'Aeromodelaje',
'Águilas',
'Ajedrez',
'Ala Delta',
'Álbumes de Música',
'Alusivos',
'Análisis de Escritura a Mano'
];
render() {
return (<MultiSelectComponent id="diacritics" ignoreAccent={true} allowFiltering={true} dataSource={this.diacriticsData} placeholder="e.g: aero"/>);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
export default class App extends React.Component<{}, {}> {
private diacriticsData: string[] = [
'Aeróbics',
'Aeróbics en Agua',
'Aerografía',
'Aeromodelaje',
'Águilas',
'Ajedrez',
'Ala Delta',
'Álbumes de Música',
'Alusivos',
'Análisis de Escritura a Mano'];
public render() {
return (
<MultiSelectComponent id="diacritics" ignoreAccent={true} allowFiltering={true} dataSource={this.diacriticsData} placeholder="e.g: aero" />
);
}
}
ReactDOM.render(<App />, document.getElementById('sample'));
[Functional-component]
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const diacriticsData = [
'Aeróbics',
'Aeróbics en Agua',
'Aerografía',
'Aeromodelaje',
'Águilas',
'Ajedrez',
'Ala Delta',
'Álbumes de Música',
'Alusivos',
'Análisis de Escritura a Mano'
];
return (<MultiSelectComponent id="diacritics" ignoreAccent={true} allowFiltering={true} dataSource={diacriticsData} placeholder="e.g: aero"/>);
}
ReactDOM.render(<App />, document.getElementById('sample'));
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App(){
const diacriticsData: string[] = [
'Aeróbics',
'Aeróbics en Agua',
'Aerografía',
'Aeromodelaje',
'Águilas',
'Ajedrez',
'Ala Delta',
'Álbumes de Música',
'Alusivos',
'Análisis de Escritura a Mano'];
return (
<MultiSelectComponent id="diacritics" ignoreAccent={true} allowFiltering={true} dataSource={diacriticsData} placeholder="e.g: aero" />
);
}
ReactDOM.render(<App />, document.getElementById('sample'));