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

Filter grid filter option not filter when using the UrlAdaptor

I am new to the Syncfusion, and I am having an issue when using the UrlAdaptor. When I try to include the filter options with the UrlAdaptor the results are not rebinding in the filter window. If I place a breakpoint I can see the results being return, but the filter window never shows the data.

However, if I don’t use the UrlAdaptor and just use the ViewBag the filtering works as expected.

 

Below is a screenshot of the behavior I am describing when using the UrlAdaptor :

@(Html.EJS().Grid<object>("DefaultPaging2").DataSource(ds => { ds.Url("/Home/Get").Adaptor("UrlAdaptor"); }).Columns(col =>
{
    col.Field("OrderId").HeaderText("Order ID").Width("120").Filter(new {type = "CheckBox"}).Add();
})
      .AllowSorting().AllowFiltering().FilterSettings(filter => filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu))
      .Height("300")
      .Render())

Here is the behavior when I am using the viewbag instead of the UrlAdaptor :

 

@(Html.EJS().Grid("DefaultPaging").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
    col.Field("OrderId").HeaderText("Order ID").Width("120").Filter(new {type = "CheckBox"}).Add();
})
.AllowSorting().AllowFiltering().FilterSettings(filter => filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu))
      .Height("300")
      .Render())


3 Replies

PS Pavithra Subramaniyam Syncfusion Team June 25, 2019 08:37 AM UTC

Hi Tucker, 
 
Thanks for contacting Syncfusion support. 
 
we have validated your requirement. We suspect that you have not handled the on-demand actions in server-side. While using remote data we need to handle Grid actions such as filtering, Sorting, etc., in server-side. 
 
We have prepared a sample for your convenience. Please find the below code snippet and sample and documentation link for more information. 
 
Index.cshtml 
<div class="control-section"> 
    @Html.EJS().Grid("DefaultPaging").DataSource(ds => ds.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor").InsertUrl("/Home/Insert").RemoveUrl("/Home/Remove").UpdateUrl("/Home/Update")).Columns(col => 
{ 
 
    col.Field("OrderID").HeaderText("Order ID").Width("120").Filter(new { type = "CheckBox" }).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("CustomerID").HeaderText("Customer Name").Width("170").Add(); 
    col.Field("OrderDate").HeaderText("Order Date").Width("130").EditType("datepickeredit").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("ShipCountry").EditType("dropdownedit").HeaderText("Ship Country").Width("150").Add(); 
 
}).AllowPaging().Toolbar(new List<string> 
        () { "Add", "Edit", "Delete", "Update", "Cancel" }).AllowFiltering().FilterSettings(filter => filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu)).EditSettings(edit => { edit.AllowEditing(true).AllowAdding(true).AllowDeleting(true); }).Render() 
</div> 
 
HomeController.cs 
public ActionResult UrlDatasource(TestDm dm) 
        { 
             
            IEnumerable DataSource = orddata.ToList(); 
            DataOperations operation = new DataOperations(); 
 
            if (dm.Search != null && dm.Search.Count > 0) 
            { 
                DataSource = operation.PerformSearching(DataSource, dm.Search);  //Search 
            } 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                DataSource = operation.PerformSorting(DataSource, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator); 
            } 
            int count = DataSource.Cast<OrdersDetails>().Count(); 
            if (dm.Skip != 0) 
            { 
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging 
            } 
            if (dm.Take != 0) 
            { 
                DataSource = operation.PerformTake(DataSource, dm.Take); 
            } 
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 
 
 
 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Pavithra S. 
 



TH Tucker Houston June 26, 2019 01:38 PM UTC

Thank you Pavithra
I did not have return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); I was just returning Json(new {result = DataSource, count = count})


PS Pavithra Subramaniyam Syncfusion Team June 27, 2019 10:33 AM UTC

Hi Tucker, 
 
Thanks for your update. 
 
We are glad to know that you have fixed the problem.  
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


Loader.
Live Chat Icon For mobile
Up arrow icon