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.
Unfortunately, activation email could not send to your email. Please try again.

Filter question

Thread ID:

Created:

Updated:

Platform:

Replies:

130240 May 1,2017 06:41 PM May 3,2017 01:54 AM ASP.NET Core 3
loading
Tags: Grid
R Brian Lindahl
Asked On May 1, 2017 06:41 PM

Is it possible to change the query type for a string column? I know that the docs say "Always `StartsWith` operator will be used for string filter"... but I've got a situation where it'd be very handy to use "Contains" rather than "StartsWith".

Saravanan Arunachalam [Syncfusion]
Replied On May 2, 2017 04:35 AM

Hi Brian, 
Thanks for contacting Syncfusion’s support. 
We have achived your requirement by using “create” event of Grid control. In the create event, we have bound the open event for the filter dialog and we have changed the item from the ejDropDownList by using selectItemByValue method in the open event. Please refer to the below code example and online documentation link. 
<ej-grid id="FlatGrid" allow-paging="true" allow-filtering="true" create="onCreate"> 
    <e-filter-settings filter-type="menu"></e-filter-settings> 
    . . . 
</ej-grid> 
<script type="text/javascript"> 
    function onCreate() { 
        if (this.model.allowFiltering && this.model.filterSettings.filterType == "menu") { 
            $("#" + this._id + "_" + "stringDlg").ejDialog({ 
                //bind the open event for the string filter dialog 
                open: function (args) { 
                    var drpobj = this.element.find(".e-dropdownlist").ejDropDownList("instance"); 
                    //changed as Contains rather than startsWith 
                    drpobj.selectItemByValue("Contains"); 
                } 
            }) 
        } 
    } 
</script> 
 
Regards, 
Saravanan A. 


R Brian Lindahl
Replied On May 2, 2017 10:42 AM

is this possible in the "filter bar" mode?

Saravanan Arunachalam [Syncfusion]
Replied On May 3, 2017 01:54 AM

Hi Brian, 
We have analyzed your requirement and achieved it by using filterBarTemplate feature of Grid control and please refer to the below code example. 
<ej-grid id="FlatGrid" datasource="ViewBag.dataSource" allow-paging="true" allow-filtering="true"> 
    . . . 
    <e-columns> 
        . . .  
        <e-column field="ShipCountry" header-text="Ship Country" filter-bar-template="@(new FilterBarTemplate() {Create="create", Read="read",Write="write" })"> 
 
        </e-column> 
    </e-columns> 
</ej-grid> 
<script type="text/javascript"> 
    function create(args) { 
        return "<input>"; 
    } 
    function write(args) { 
        //Bind the keyup event for the filterbar input element 
        args.element.bind("keyup", ej.proxy(args.column.filterBarTemplate.read, this, args)); 
    } 
    function read(args) { 
        //Filter the column with contains operator 
        this.filterColumn(args.column.field, "contains", args.element.val(), "and", true); 
    } 
</script> 
 
We have created a sample that can be downloaded from the below link, 
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.

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.

;