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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to do real time search with multiple keywords

Thread ID:

Created:

Updated:

Platform:

Replies:

129830 Apr 5,2017 12:01 PM UTC Apr 10,2017 05:40 AM UTC ASP.NET Web Forms 3
loading
Tags: Grid
Velu
Asked On April 5, 2017 12:01 PM UTC

Hi Syncfusion Support,

Please help me to do real time search with multiple keywords.

I'm using Syncfusion Grid control with search text box. It can give result when I search for, but when I click on search button.

My requirement is, it has to give search result when start typing which means key press/text change like real time search result. Is it possible?

And also search with multiple keywords like "engine,wheel,tyre" so that it would search all the columns and return rows.

Regards,
Velu

Saravanan Arunachalam [Syncfusion]
Replied On April 6, 2017 11:05 AM UTC

Hi Velu, 
Thanks for contacting Syncfusion’s support. 
Query 1: it has to give search result when start typing which means key press/text change 
We have achieved your requirement by using Create event of Grid control. In the Create event, we have bound the jQuery’s keyup event for the the search input box in the toolbar and perform search based on the inputed text by using search method Grid control. Please refer to the below code example. 
<ej:Grid ID="FlatGrid" runat="server" AllowPaging="true"> 
            . . . 
            <ClientSideEvents ActionComplete="actionComplete" ActionBegin="actionBegin" Create="onCreate" ToolbarClick="toolbarClick" />     
        </ej:Grid> 
function onCreate(args) { 
            $(".e-gridtoolbar").find(".e-gridsearchbar").keyup(function (e) { 
                setTimeout(function () { 
                    var str = $(e.target).val(); 
                    $("#Grid").ejGrid("search", str); 
                }, 1000) 
            }) 
        } 
 
Query 2: search with multiple keywords like "engine, wheel, tyre" 
We don’t have inbuilt support to search multiple terms and we have already logged a feature request “Need to give multiple search support to Datamanager” and it can be impleamented any of our upcoming release. 
And we have achieved your reqiurement in workaround by using ActionComplete and ToolbarClick event of Grid control. In the ActionComplete event, we have performed the searching with multiple terms when requestType is searching and please refer to the below code example and jsplayground sample. 
<ej:Grid ID="FlatGrid" runat="server" AllowPaging="true"> 
            . . . 
            <ClientSideEvents ActionComplete="actionComplete" ActionBegin="actionBegin" Create="onCreate" ToolbarClick="toolbarClick" />     
        </ej:Grid> 
function toolbarClick(args) { 
            if (args.itemName == "Search" && args.model.searchSettings.key == "" && searchApplied && $("#Grid_searchbar").val() == "") { 
                searchApplied = false; 
                searchKey = ""; 
                keyValue = []; 
            } 
        } 
        function actionBegin(args){ 
             if (args.requestType == "searching" && this.model.searchSettings.key == "")  
                this.model.query.queries = []; 
        } 
        function actionComplete(args) { 
            if (args.requestType == "searching") { 
                 if (this.model.searchSettings.key != "") { 
                    Searchkeyword = this.model.searchSettings.key.split(","); 
                    if (Searchkeyword.length > 1) { 
                        if (args.requestType == "searching") { 
                            if (this.model.searchSettings.key != "") { 
                                // split based on the (,) 
                                searchKey = this.model.searchSettings.key; 
                                keyValue = args.keyValue.split(","); 
                            } 
                            this.clearSearching(); 
                            // searching apply 
                            if (this.commonQuery.queries.length > 0) 
                                this.commonQuery.queries = []; 
                            var i,pred = ej.Predicate("CustomerID", "contains", $.trim(keyValue[0]), true); 
                            for(i=1;i<keyValue.length;i++){ 
                                pred = pred["or"]("CustomerID", "contains", $.trim(keyValue[i]), true); 
                            }    
                            this.commonQuery.where(pred); 
                            searchApplied = true; 
                            $(".e-ejinputtext.e-gridsearchbar").val(searchKey) 
                            this.refreshContent(); 
                            this.model.allowSearching = false; 
                        } 
                        $("#Grid_searchbar").val(searchKey); 
                        this.model.searchSettings.key = searchKey; 
                    } 
                } 
           } 
        } 
 
Note: Limitation of this workaround is that we can perform searching with multiple terms on any one of the field. 
Regards, 
Saravanan A. 


Velu
Replied On April 7, 2017 05:16 AM UTC

Hello Saravanan,

Thank you very much for your extended support. It's really worked great as I expected.

Syncfusion support is always great because of immediate reply with examples.... :)

Regards,
Velu

Saravanan Arunachalam [Syncfusion]
Replied On April 10, 2017 05:40 AM UTC

Hi Velu,  
Thanks for your update.       
We are happy that the provided information helped you. 
Regards, 
Saravanan A. 


CONFIRMATION

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.

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

;