- Home
- Forum
- JavaScript - EJ 2
- Search in Excel Filter return no values
Search in Excel Filter return no values
Hi,
I'm using a Grid with a DataManager connected to a REST endpoint.
When the page loads, the filters are correctly populated : see #1
However, after performing a search, all filter options disappear : see #2
I can see that a query is sent to the data source: see #3
and the response contains data : see #4
There are no errors in the browser console.
What should I look into to resolve this?
Thank you,
Attachment: ScreenShot_cfb15dae.png
I identified the root cause of the issue: my REST endpoint was not handling the requiresCounts property correctly. This property is set to true during the initial load or refresh of the datasource, but it is not set during filtering operations, and I was always sending the results/count .
Hope that helps
Thank you for the detailed explanation. Based on your findings, you are correct — the issue occurs because the REST endpoint does not properly handle the requiresCounts property during filtering operations.
The Grid expects different response formats based on whether the requiresCounts parameter is present in the query:
- For general Grid actions (such as initial load, paging, sorting, or refreshing the data source):
- The
requiresCountsparameter will betrue. - In this case, the server must return a response in the format
{ result: [...], count: totalCount }. - For search or filtering within the filter popup (Excel or menu filter search):
- The
requiresCountsparameter will beundefined. - Here, the server should return a plain array of objects — only the filtered data without wrapping it inside a
{ result: [...], count: ... }object.
requiresCounts parameter and return the response accordingly.Please refer to the code below for more information:
Code Example : public object Post([FromBody] DataManagerRequest DataManagerRequest) { // Retrieve data from the data source (e.g., database) IQueryable<OrdersDetails> DataSource = GetOrderData().AsQueryable(); QueryableOperation queryableOperation = new QueryableOperation(); // Initialize DataOperations instance // Handling filtering operation if (DataManagerRequest.Where != null && DataManagerRequest.Where.Count > 0) { DataSource = queryableOperation.PerformFiltering(DataSource.Cast<OrdersDetails>(), DataManagerRequest.Where, DataManagerRequest.Where[0].Operator); } // Get the total count of records int totalRecordsCount = DataSource.Count(); // Handling paging operation. if (DataManagerRequest.Skip != 0) { DataSource = queryableOperation.PerformSkip(DataSource, DataManagerRequest.Skip); } if (DataManagerRequest.Take != 0) { DataSource = queryableOperation.PerformTake(DataSource, DataManagerRequest.Take); } // Return data based on the request return DataManagerRequest.RequiresCounts ? new { result = DataSource, count = totalRecordsCount }: new { result = DataSource }; } |
Attachment: UrlAdaptorJS_57f37bb8.zip
- 2 Replies
- 2 Participants
-
EC Ecaldima
- May 9, 2025 04:27 PM UTC
- May 12, 2025 11:14 AM UTC