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

How can I filter the grid when the datasource is set with URL

I have a grid like this:
//.ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.Search); }); })
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().ShowDeleteConfirmDialog(); })
.Columns(col =>
col.Field("Title").HeaderText("Name").ValidationRules(v => v.AddRule("required", true)).Width(300).Add();
col.Field("ExternalId").HeaderText("External Id").TextAlign(TextAlign.Right).Add();
col.Field("JobTypeId").HeaderText("Job Type").ValidationRules(v => v.AddRule("required", true)).Width(150).ForeignKeyField("JobTypeId").ForeignKeyValue("Name").DataSource(ViewBag.JobTypes).Add();
col.Field("Color").HeaderText("Color").ValidationRules(v => v.AddRule("required", true)).Width(75).Add();
.Datasource(ds => ds.URL("Jobs/GetData").UpdateURL("Jobs/Update").InsertURL("Jobs/Insert").RemoveURL("Jobs/Delete").Adaptor(AdaptorType.UrlAdaptor))
.ToolbarSettings(toolbar =>
toolbar.ShowToolbar().ToolbarItems(items =>
And the action Jobs/GetData looks like this:
public JsonResult GetData(DataManager dm)
var result = new DataResult();
var jobs = new List();
var operation = new DataOperations();
var today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
foreach (var job in db.Jobs.Include(j => j.EmployeeJobs).ToList())
decimal planned = 0;
foreach(var employeeJobs in job.EmployeeJobs)
planned += (decimal)Utils.IntersactionWeekDays(today, DateTime.MaxValue, employeeJobs.StartTime, employeeJobs.EndTime) * 8;
jobs.Add(new JobModel()
Id = job.Id,
Title = job.Title,
ExternalId = job.ExternalId,
JobTypeId = job.JobTypeId,
ADP = job.ADP,
Deadline = job.Deadline,
ActualHours = job.ActualHours,
OrderedHours = job.OrderedHours,
Color = job.Color,
PlannedHours = planned,
TotalHours = job.ActualHours + 0
result.result = jobs;
result.count = jobs.Count();
if (dm.Skip > 0)
result.result = operation.PerformSkip(result.result, dm.Skip);
if (dm.Take > 0)
result.result = operation.PerformTake(result.result, dm.Take);
return Json(result, JsonRequestBehavior.AllowGet);
How can I make the filtering working in this case? Please note that I'm using Entity Framework.

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team March 17, 2017 03:32 PM UTC

Hi Cornel, 
Thanks for contacting Syncfusion support. 
Query: How can I make filtering in the Url Adaptor enabled in Grid. 
We have analyzed your query and based on your requirement we suggest you to handle the filtering in the server side itself. 
While using UrlAdaptor, you can handle grid operation (paging/filtering/searching/sorting) in server side. When performing paging, filtering, sorting, editing operations on the grid queries are passed to the server side using DataManager class and using DataOperations class methods you perform server-side operations. 
Refer the below code example. 
              .Datasource(ds => ds.URL("/Grid/DataSource").Adaptor(AdaptorType.UrlAdaptor))   
public ActionResult DataSource(DataManager dm)   
            IEnumerable DataSource = new NorthwindDataContext().OrdersViews.ToList();   
            DataResult result = new DataResult();   
            DataOperations operation = new DataOperations();   
            result.result = DataSource;   
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting   
                result.result = operation.PerformSorting(DataSource, dm.Sorted);   
            if (dm.Where != null && dm.Where.Count > 0) //Filtering   
                result.result = operation.PerformWhereFilter(DataSource, dm.Where, dm.Where[0].Operator);   
            result.count = result.result.AsQueryable().Count();   
            if (dm.Skip > 0)   
                result.result = operation.PerformSkip(result.result, dm.Skip);   
            if (dm.Take > 0)   
                result.result = operation.PerformTake(result.result, dm.Take);   
            return Json(result, JsonRequestBehavior.AllowGet);   
We have prepared a sample and it can be downloadable from the below location. 
Refer the following knowledge base 
Refer the help documentation. 
Thavasianand S. 

CA Cornel Amarandei March 20, 2017 12:34 PM UTC

Hi Thavasianand,

Thanks for your information. It worked.


TS Thavasianand Sankaranarayanan Syncfusion Team March 21, 2017 06:01 AM UTC

Hi Cornel, 

We are happy that the problem has been solved. 
Please get back to us if you need any further assistance.  
Thavasianand S. 

Live Chat Icon For mobile
Up arrow icon