- Home
- Forum
- ASP.NET MVC
- Remove filter from column
Remove filter from column
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
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"); } |
Sample: http://www.syncfusion.com/downloads/support/forum/123194/ze/Sample119799992529428
Regards,
Prasanna Kumar N.S.V
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
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.
Sample: http://www.syncfusion.com/downloads/support/forum/123194/ze/Sample119799_(2)1996636022
Regards,
Prasanna Kumar N.S.V
- 3 Replies
- 2 Participants
-
JS Jeffrey Stone
- Feb 25, 2016 12:03 AM UTC
- Feb 26, 2016 05:41 AM UTC