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

Remove filter from column

I know that I can use something similar to remove all filters from a grid:

var gridObj = $("#Grid").ejGrid("instance");
gridObj.model.filterSettings.filteredColumns = [];
gridObj.refreshContent();

However, all I really want to do is remove the filters from a specific column:

Here is an example of how the filter is applied:
var gridObj = $("#AccountOrderGroupsGrid").ejGrid("instance");
gridObj.filterColumn("@nameof(AccountOrderGroup.OnHandQuantity)", ej.FilterOperators.notEqual, 0, "and", true);

How can I remove only this filter?

Thanks, Jeff
           

3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team February 25, 2016 06:31 AM UTC

Hi Jeffrey,

Thanks for contacting Syncfusion support.

To remove the filter for a specific column, we suggest you to use  clearFiltering method of ejGrid. In this method we need to pass the field name as a parameter.

Please find the code example and sample:


@Html.EJ().Button("buttonnormal").Text("RemoveFilter").ClientSideEvents(eve => eve.Click("click"))

@(Html.EJ().Grid<Sample119799.OrdersView>("FlatGrid")

        .Datasource((IEnumerable<object>)ViewBag.datasource)

        .AllowPaging()    /*Paging Enabled*/

        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })

        .AllowSorting()

        .AllowFiltering()

        .FilterSettings(filter => { filter.FilterType(FilterType.Menu); })

        .ToolbarSettings(toolbar =>

        {

            toolbar.ShowToolbar().ToolbarItems(items =>

            {

                items.AddTool(ToolBarItems.Add);

                items.AddTool(ToolBarItems.Edit);

                items.AddTool(ToolBarItems.Delete);

                items.AddTool(ToolBarItems.Update);

                items.AddTool(ToolBarItems.Cancel);

            });

        })

        .ClientSideEvents(eve => eve.Create("action").ActionComplete("complete"))

        .Columns(col =>

        {

            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();

            col.Field("CustomerID").HeaderText("Customer ID").ValidationRules(v => v.AddRule("required",true).AddRule("minlength", 3)).Width(80).Add();

            col.Field("EmployeeID").HeaderText("Employee ID").ValidationRules(v => v.AddRule("required",true)).TextAlign(TextAlign.Right).Width(75).Add();

            col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add();

        }))


<script type="text/javascript">

    function action(args) {

        var grid = $("#FlatGrid").ejGrid("instance");

        grid.filterColumn("CustomerID", "equal", "ALFKI", "and", true);

    }


// Remove Filter for the particular column


    function click(args) {

        var grid = $("#FlatGrid").ejGrid("instance");

        grid.clearFiltering("CustomerID");

    }
</script>



Sample: http://www.syncfusion.com/downloads/support/forum/123194/ze/Sample119799992529428

Regards,
Prasanna Kumar N.S.V



JS Jeffrey Stone February 25, 2016 12:47 PM UTC

Thanks for the quick reply.

The solution doesn't appear to work when using a FilterType of Excel. I received the following error:

TypeError: this._excelFilter._predicates[0] is undefined
http://localhost:54040/Scripts/ej/ej.web.all.min.js
Line 10

Would you please look into this.

Regards,
Jeff






PK Prasanna Kumar Viswanathan Syncfusion Team February 26, 2016 05:41 AM UTC

Hi Jeffrey,

We have checked with the Excel filter and we were able to remove the filter for the particular column. To reproduce the issue, we need the following details.


1.       Scenario to reproduce the issue.

2.       Code Example.

3.       Essential Studio Version details.


4.       Reproduce the issue in the following sample.


Sample: http://www.syncfusion.com/downloads/support/forum/123194/ze/Sample119799_(2)1996636022

Regards,
Prasanna Kumar N.S.V


Loader.
Live Chat Icon For mobile
Up arrow icon