We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

search on multiple words

Thread ID:





147244 Sep 3,2019 07:21 AM UTC Sep 5,2019 07:09 AM UTC ASP.NET Core - EJ 2 1
Tags: DataGrid
Asked On September 3, 2019 07:21 AM UTC


How would I do the same (query 2 in particular) in the following grid? It seems that the used function ej.predicate() is not available?

<ejs-grid id="Grid" dataSource="ViewBag.datasource" toolbar="@(new List<string>() {"Search" })" allowPaging="true"> <e-grid-pagesettings pageCount="5"></e-grid-pagesettings> <e-grid-columns> <e-grid-column field="CategoryName" headerText="Category Name" textAlign="Right" width="160"></e-grid-column> <e-grid-column field="ProductName" headerText="Product Name" width="170"></e-grid-column> <e-grid-column field="QuantityPerUnit" headerText="Quantity Per Unit" textAlign="Right" width="170"></e-grid-column> <e-grid-column field="UnitsInStock" headerText="Units in Stock" textAlign="Right" width="170"></e-grid-column> <e-grid-column field="Discontinued" headerText="Discontinued" width="150" displayAsCheckBox="true" textAlign="Center" type="boolean"></e-grid-column> </e-grid-columns> </ejs-grid>

Thavasianand Sankaranarayanan [Syncfusion]
Replied On September 5, 2019 07:09 AM UTC

Hi Koen, 
Greetings from Syncfusion support. 
We can search the text value based on typing the values in search textbox instead of click on search button using created event and we have bind actionBegin event and prevent the default search action and customize the filter query based on the multiple keywords(search). Please refer the below code example and sample for more information.  
<ejs-grid id="Grid" dataSource="ViewBag.datasource" allowPaging="true" toolbar="@(new List<string>() {"Search" })"created="created" actionBegin="actionBegin" actionComplete="actionComplete">      
        .    .     .    .          
    var debounceTimer = null;  
    var gquery, val;  
    function created(e) {          
        document.getElementById("Grid_searchbar").addEventListener('keyup', (event) => {  
            clearTimeout(debounceTimer); // you can customize as per your requirement(Searh action trigger while KEYPRESS)  
            debounceTimer = setTimeout(() => { searchFun(event); }, 500);  
    function actionBegin(args) {          
        if (args.requestType == "searching") {  
            var grid = document.getElementsByClassName("e-grid")[0].ej2_instances[0];  
            const keys = args.searchString.split(','); //Split your search text and get the values  
            var flag = true;  
            var predicate;  
            if (keys.length > 1) {  
                if (this.searchSettings.key !== '') {  
                    val = args.searchString;  
                    // preparing filter query  
                    keys.forEach((key) => {  
                        this.getColumns().forEach(col => {  
                            if (flag) {  
                                predicate = new ej.data.Predicate(col.field, 'contains', key);  
                                flag = false;  
                            } else {  
                                var pre = new ej.data.Predicate(col.field, "contains", key);  
                                predicate = predicate.or(pre);                                                            }  
                    gquery = this.query;  
                    this.query = new ej.data.Query().where(predicate);                      
                    this.searchSettings.key = '';  
    function actionComplete(e) {  
        if (e.requestType === 'refresh') {  
            this.query = gquery;  
            document.getElementById(this.element.id + '_searchbar').value = val;  
    function searchFun(event) {  
        var grid = document.getElementsByClassName("e-grid")[0].ej2_instances[0];  
        var value = event.target.value;  
Note: We need to the predicate as ej.data.Perdicate() to use in EJ 2 Grid component.  
Refer the help documentation. 

Thavasianand S. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon