Hi Társis,
Thanks for contacting Syncfusion support.
Query: How can I change the default filter operator 'startswith' to 'contains' in the grid?
We have validated your query and you can achieve your requirement by using below way.
Here, we have changed the default filter operator from ‘startwith’ to ‘contains’ by using dataBound event. Please find the below code example and sample for your reference.
[code example]
...
export class Filtering extends SampleBase {
constructor() {
super(...arguments);
...
}
dataBound(){
Object.assign(this.gridInstance.filterModule.filterOperators, {startsWith: 'contains'});
}
...
render() {
return (<div className='control-pane'>
<div className='control-section row'>
<div style={{ padding: '14px 0' }}>
<div className="select-wrap">
<DropDownListComponent id="ddlelement" dataSource={this.filData} fields={this.fields} change={this.onChange.bind(this)} placeholder="Select category to filter" width="200px"/>
</div>
</div>
<GridComponent dataSource={categoryData} allowPaging={true} dataBound={ this.dataBound.bind(this)} ref={grid => this.gridInstance = grid} pageSettings={{ pageSize: 10, pageCount: 5 }} allowFiltering={true}>
...
<Inject services={[Filter, Page]}/>
</GridComponent>
</div>
</div>);
}
}
render(<Filtering />, document.getElementById('sample')); |
Please find the sample in below link.
Please get back to us if you need further assistance.
Regards,
J Mohammed Farook.