- Home
- Forum
- Angular - EJ 2
- Highlight Filtering Characters in Popup
Highlight Filtering Characters in Popup
Hello Team,
I want to Highlight Typed Characters on Popup. Eg. If I type "del" and popup will show records started with Characters del like Delhi. "Del" will be highlighted in Delhi.
How to achieve this task.
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
BC
Berly Christopher
Syncfusion Team
January 26, 2021 10:57 AM UTC
Hi Nagendra,
Greetings from Syncfusion support.
We can achieve the filtering with highlight feature with help of highlightSearch method as mentioned in the below code example.
|
// maps the appropriate column to fields property
public fields: Object = {
text: "Name",
value: "Code",
itemCreated: (e: any) => {
highlightSearch(e.item, this.queryString, true, "StartsWith");
}
};
// filtering event handler to filter a Country
public onFiltering: EmitType<FilteringEventArgs> = (
e: FilteringEventArgs
) => {
// take text for highlight the character in list items.
this.queryString = e.text;
let query: Query = new Query();
//frame the query based on search string with filter type.
query =
e.text !== "" ? query.where("Name", "startswith", e.text, true) : query;
//pass the filter data source, filter query to updateData method.
e.updateData(this.data, query);
};
} |
Regards,
Berly B.C
Marked as answer
NG
Nagendra Gupta
January 28, 2021 05:27 AM UTC
Hi Berly,
Thanks for your update, but unfortunately your given example is not working with the column template option. Please suggest how to achieve this task with the template option.
Regards,
Nagendra Gupta
BC
Berly Christopher
Syncfusion Team
January 28, 2021 03:19 PM UTC
Hi Nagendra,
While using the template option, the data will be fetched with some delay. So, we suggest you to call the highlightSearch method in the setTimeOut as mentioned in the below code example.
|
public fields: Object = {
text: "Name",
value: "Code",
itemCreated: (e: any) => {
setTimeout(() => {
highlightSearch(e.item, this.queryString, true, "StartsWith");
});
}
}; |
Regards,
Berly B.C
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
NG Nagendra Gupta
- Jan 25, 2021 09:19 AM UTC
- Jan 28, 2021 03:19 PM UTC