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

Remove filter from column

Thread ID:

Created:

Updated:

Platform:

Replies:

123194 Feb 25,2016 12:03 AM UTC Feb 26,2016 05:41 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Jeffrey Stone
Asked On February 25, 2016 12:03 AM UTC

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
           

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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


Jeffrey Stone
Replied On 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





Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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


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

;