Comments (7)
Hi @taysonvo,
We have checked your query and the cause of this behavior is the data remains with tag elements in dataSource. So when filtering Grid compares the given value with the data as in dataSource. This is the default behavior of Grid Filtering.
However, we have prepared a custom sample to achieve your requirement. In that sample, we have extended a Custom adaptor from JSONAdaptor to modify the default filtering (onWhere) method and used custom Filter UI (Essential JavaScript 2 TextBox) for the column having data with tag element. Please refer to the sample code, documentation link, and sample link.
[component.html]
<ejs-grid #grid [dataSource]='data' allowFiltering='true' [filterSettings]='filterSettings'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign="Right"></e-column>
<e-column field='CustomerID' headerText='CustomerID' [filter]= 'filter' width='120' format='C2' textAlign="Right"></e-column>
. . .
</e-columns>
</ejs-grid>
[component.ts]
class CustomFilterAdaptor extends JsonAdaptor { // CustomAdaptor extended from JsonAdaptor
public onWhere(ds: Object[], e: { validate: Function }): Object[] {
if (!ds || !ds.length) { return ds; }
return ds.filter((obj: Object) => {
if (e) {
let obj1 = Object.assign({}, obj);
obj1['OrderID'] = obj1['OrderID'].replace(/<[^>]*>/g, ''); //replaces the tag elements of
return e.validate(obj1); original data
}
});
}
}
@Component({
selector: 'control-content',
templateUrl: 'app.html'
})
export class DefaultComponent implements OnInit {
public data: DataManager;
public filterSettings: Object;
public orderData = [{
'OrderID': 10248,
'CustomerID': '<a href="#">VINET</a>',
'OrderDate': '1996-07-04T00:00:00.000Z',
. . .
},
];
public ngOnInit(): void {
this.data = new DataManager(this.orderData).executeLocal(new Query());
this.data.adaptor = new CustomFilterAdaptor;
this.filterSettings = { type: 'Menu' };
this.filter = {
ui: {
create: (args: { target: Element, column: Object }) => {
let flValInput: HTMLElement = createElement('input', { className: 'e-input flm' });
args.target.appendChild(flValInput);
},
write: (args: {
column: Object, target: Element, parent: any,
filteredValue: number | string
}) => {
if(args.filteredValue !=undefined){
(<HTMLInputElement>document.querySelector('.e-input.flm')).value = <string>args.filteredValue;
}
},
read: (args: { target: Element, column: any, operator: string, fltrObj: Filter }) => {
args.fltrObj.filterByColumn(args.column.field, args.operator, (<HTMLInputElement>document.querySelector('.e-input.flm')).value);
}
}
};
}
}
Documentation : 1. http://ej2.syncfusion.com/angular/documentation/grid/databinding.html#custom-adaptor
2. http://ej2.syncfusion.com/angular/documentation/grid/filtering.html#custom-component-in-filter-menu
Sample : https://plnkr.co/edit/NMzihdjBkcbzz95ikPFi?p=preview
Regards,
Pavithra S.
from ej2-javascript-ui-controls.
Sorry, this is working fine now, pls ignore.
from ej2-javascript-ui-controls.
Hi supporters,
Im not sure why in plunker it working but in my code it doesnt work.
The issue is because of the querySelector('#OrderID.text_filterBarcell')
is return null. Because the id content the '.'
Please show me how to fix that, or tell me which version of ej2 that the issue was resolved.
Many thanks
from ej2-javascript-ui-controls.
Hi Taysonvo,
We have checked your query and the reported issue has been already fixed in our Essential JavaScript 2 release version 15.4.26. Please update your Essential JavaScript 2 packages to the latest version.
Regards,
Pavithra S.
from ej2-javascript-ui-controls.
Hi @Pavithra15 ,
Thanks for your answer but there is another issue :
If the value is containing the "a" tag with a href link like below screenshot then the filter will not working. Because the value that the grid understand now is including the "a" tag, href and the value, not only the value.
Should I open a new issue for that ?
Regards,
Son
from ej2-javascript-ui-controls.
Hi @taysonvo ,
We have checked your query and could you please provide the below details that will be helping us to provide a better solution as early as possible.
- Which type of filtering are you using, for example, filter menu or checkbox?
- Are you using dataSource with tag elements?
Regards,
Pavithra S.
from ej2-javascript-ui-controls.
Hi @Pavithra15 ,
Sorry for very late response due to my long vacation. PSB my answers:
Regards,
Son
from ej2-javascript-ui-controls.
Related Issues (20)
- PdfViewer: Disabling the form-field editor via toolbar items causes an exception when interacting with form fields HOT 7
- PdfViewer: When creating a signature field the background color is ignored. HOT 2
- Data Grid column template not rendering in React HOT 4
- Security issue HOT 4
- visual picker HOT 2
- web component support HOT 2
- CSS styles are not exported from the syncfusion packages HOT 4
- CSS explicitly needs to be set as having side effects in order to work with Parcel. HOT 4
- My scheduler component crashes since resourceCollection can be empty HOT 2
- spreadsheet to keep zero digit HOT 2
- Why is the version of `@types/node` set at a static 18.11.11? I get an "arrow key" prompt. HOT 1
- Error alert when opening excel file HOT 3
- npm run error HOT 3
- Firefox: no execCommand HOT 2
- Content Security Policy requires 'unsafe-eval' for script-src HOT 2
- this.lastPos scope is window and not TreeInterSectionObserver HOT 3
- unset-value 1.0 has a high security vulnerability, fixed in 2.0.1 HOT 3
- The esm files inside `dist/es6` folder should end with `.mjs` HOT 5
- Integration with Azure Data lake Storage V2 HOT 1
- npm install @syncfusion/[email protected] fails (missing dep) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ej2-javascript-ui-controls.