- Home
- Forum
- JavaScript - EJ 2
- Filtering with multiple set values does not work
Filtering with multiple set values does not work
Hi,
I am using ej2 JS 18.4.43. I have created a reproducible environment. I will describe the issue in this demo.
The grid is filtered on CustomerId with startsWith value 'E' by default. Run the demo and open dev tools on network tab. Then, when you click on Employee column header and it shows the filter menu and spinner is shown. It generates URL '
https://services.odata.org/V4/Northwind/Northwind.svc/Orders/?$apply=groupby((CustomerID,EmployeeID))&$count=true&$top=1000'. The request fails with 400, but it should return 200 with data limited to 1000 items. Two things are wrong with the request:
- The first thing is that it generates $grouby with CustomerID and EmployeeID. However, imho it should generate only $groupby with EmployeeID and $filter with CustomerID.
- The second thing is that if the datasource suffieciently large and there are let's say more than 1000 employee with the name, which begins with 'A', then 1000 rows are filtered on client side and none of them are displayed in the filter menu because of the default filter({ field: "CustomerID", operator: "startsWith", value: "E" }).
Please note that I was not able to find any public odata fake api that has large datasource. So, just change the api url with OData endpoint that provides enough data.
SIGN IN To post a reply.
1 Reply
1 reply marked as answer
PG
Praveenkumar Gajendiran
Syncfusion Team
November 6, 2020 03:05 PM UTC
Hi Stefan,
Thanks for Contacting Syncfusion support.
We checked your query and provided sample. Based on that we would like to inform you that we have not handled filtering operation in that service, that’s why the reported problem occurs . So for this case we suggest you to preform the filtering operation based on your query in the controller path. Please refer the below code snippet for more information on this.
Code Snippet:
|
namespace EJGrid.Controllers
{
public class OrdersController : ODataController
{
// GET: Orders
NORTHWNDEntities db = new NORTHWNDEntities();
public PageResult<Order> Get(ODataQueryOptions opts)
{
List<Order> emp = db.Orders.ToList();
var data = emp.AsQueryable();
var count = data.Count();
if (opts.OrderBy != null)
data = opts.OrderBy.ApplyTo(data); //perform sort
//perform filter
if (opts.Filter != null)
data = opts.Filter.ApplyTo(data, new ODataQuerySettings()).Cast<Order>();
if (opts.Skip != null)
data = opts.Skip.ApplyTo(data, new ODataQuerySettings()); //perform skip
if (opts.Top != null)
data = opts.Top.ApplyTo(data, new ODataQuerySettings()); //perform take
return new PageResult<Order>(data, null, count);
}
}
} |
Regards,
Praveenkumar G
Marked as answer
SIGN IN To post a reply.