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.

How do I apply a filter on a grid using javascript?

Thread ID:

Created:

Updated:

Platform:

Replies:

118306 Feb 23,2015 07:01 PM Feb 24,2015 07:39 AM ASP.NET MVC 1
loading
Tags: Grid
Christine Romano
Asked On February 23, 2015 07:01 PM

I am creating the following grid.


@(Html.EJ().Grid<MerchantsViewModel>("MerchantsGrid"


).Datasource((IEnumberable<object>)Model.Merchants)

.FilterSettings(filter => { filter.ShowFilterBarStatus().StatusBarWidth(500).FilterType(FilterType.Excel).FilterBarMode(FilterBarMode

.Immediate); })

.Columns(col =>

{

col.Field("Email").HeaderText("Email(s)").Width(120).Add();

.

.

.

And I want to filter (based on an event). How would I filter on my grid data to display only the data that has aas@as.com in the Email field? 

function applyFilter(filterValue) {

var stringValue = filterValue == "All" ? "" : filterValue;

var gridObj = $("#MerchantsGrid").ejGrid("instance");

var filteredActiveData = ej.DataManager(gridObj).executeLocal(ej.Query().where("Email", ej.FilterOperators.contains, "aas@as.com", false));

}
















































}



Madhu Sudhanan P [Syncfusion]
Replied On February 24, 2015 07:39 AM

Hi Christine,

Thanks for using Syncfusion products.

We have analyzed the provided code snippet and suspect that you have passed the grid object directly to the ej.DataManager (“ as ej.DataManager(gridObj).”) instead of passing the grid datasource and hence the data was not filtered correctly.

We can filter the Email field with value “aas@as.com” from grid datasource as follows.

function applyFilter(filterValue) {

var stringValue = filterValue == "All" ? "" : filterValue;

var gridObj = $("#MerchantsGrid").ejGrid("instance");

var filteredActiveData = ej.DataManager(gridObj.model.dataSource).executeLocal(ej.Query().where("Email", ej.FilterOperators.contains, "aas@as.com", false));

}

Now in the above highlighted section, you can see that we have passed the grid datasource to ej.DataManager and now filteredActiveData will contain the filtered value.

If you want to display the filtered value in grid, then we can do as follows.

gridObj.dataSource(filteredActiveData)

For more information on performing custom or external filtering in grid, please refer the below link (Refer the External filter section in the below link).

http://help.syncfusion.com/ug/js/default.htm#!documents/filtering1.htm

Please let us know if you have any queries.

Regards,

Madhu Sudhanan. P



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.

;