- Home
- Forum
- ASP.NET MVC - EJ 2
- Filter grid filter option not filter when using the UrlAdaptor
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())
SIGN IN To post a reply.
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);
}
|
Sample: https://www.syncfusion.com/downloads/support/forum/145475/ze/145475-mvc-url-adaptor1143420276
Documentation: https://ej2.syncfusion.com/aspnetmvc/documentation/grid/data-binding/?no-cache=1#handling-on-demand-grid-actions
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.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
TH Tucker Houston
- Jun 24, 2019 02:09 PM UTC
- Jun 27, 2019 10:33 AM UTC