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

Change Filter to "Contains"

Hi, is this the correct layout needed for changing a column filter to contains? it does the auto fill ok but doesn't seem to be taking on the contains portion



 <ej:Grid ID="Grid1" runat='server' AllowFiltering="true" AllowPaging="true" CssClass="" DataSourceCachingMode="None" DataSourceID="SqlDataSource1" EnableLoadOnDemand="False" MinWidth="0">
        <Columns>

            <ej:Column AllowEditing="False" DataType="number" Visible="false" Field="id" IsIdentity="True" IsPrimaryKey="True">
            </ej:Column>
           <ej:Column DataType="string" Field="fullnameGive" AllowFiltering="true" HeaderText="Giving">

                </ej:Column>
                <ej:Column DataType="string"  Field="fullnameReceive" AllowFiltering="true" HeaderText="Receiving">
                                 <FilterBarTemplate Create="autoComplete_create" Write="autoComplete_write" Read ="autoComplete_read" />
                </ej:Column>
            <ej:Column DataType="string" Field="type" Width="190px" AllowFiltering="true" HeaderText="Type">
            </ej:Column>
            <ej:Column DataType="string" Field="description" Width="500px" AllowFiltering="true" HeaderText="Description">
            </ej:Column>
            <ej:Column DataType="date" Field="date" Width="100px" AllowFiltering="true" HeaderText="Date">
            </ej:Column>
            <ej:Column DataType="string" Visible="false" Field="isApproved">
            </ej:Column>
        </Columns>
    </ej:Grid>





         <script type="text/javascript"> 
        function autoComplete_create(args) {
            return "<input>"
        }

        function autoComplete_write(args) {
var gridObj = $('#<%= Grid1.ClientID %>').data("ejGrid");
            var data = ej.DataManager(gridObj.model.dataSource).executeLocal(new ej.Query().select("fullnameReceive"));
            args.element.ejAutocomplete({ width: "100%", dataSource: data, enableDistinct: true, focusOut: ej.proxy(args.column.filterBarTemplate.read, this, args) });
        }

        function autoComplete_read(args) {
            this.filterColumn(args.column.field, "contains", args.element.val(), "and", true)
        }

       
    </script>

1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 22, 2020 02:26 PM UTC

Hi Bill, 

Thanks for contacting Syncfusion Support. 

We have checked your query and if you want to change filter operator to “contains”, you can set the filterType property of the autoComplete as “contains”. Also by using this property you can operator as greaterthan, lessthan as per your requirement. 


Refer to the code example:- 
<script type="text/javascript"> 
    function autoComplete_create(args) { 
        return "<input>" 
    } 
 
    function autoComplete_write(args) { 
        var gridObj = $('#<%= Grid1.ClientID %>').data("ejGrid"); 
        var data = ej.DataManager(gridObj.model.dataSource).executeLocal(new ej.Query().select("fullnameReceive")); 
        args.element.ejAutocomplete({ width: "100%", dataSource: data, enableDistinct: true, filterType:"contains", focusOut: ej.proxy(args.column.filterBarTemplate.read, this, args) }); 
    } 
 
    function autoComplete_read(args) { 
        this.filterColumn(args.column.field, "contains", args.element.val(), "and", true) 
    } 
 
 
</script> 

Refer to the API Link:- 

Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon