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

EJ2 Grid Filter Menu causes endless spinner

Hello

I am using EJ 2 version 16.3.0.36 (nuget package).

I have a grid with remote data (UrlAdaptor). Filter type is "Menu". Column type is "string".

In the filter dialog I select "Starts with" and enter any text that I know leads to 0 results. Still I apply the filter.
The result is that the grid spins forever and nothing else happens (no errors in js).

On the server side I see that the DataManagerRequest contains a "Where" that contains the string I entered.
The code on the server side that I use is more or less as follows:

...
var data = _myService.GetData();
var count = data.Count();
var operation = new DataOperations();
data = operation.Execute(data, dm);

return dm.RequiresCounts ? Json(new { result = data, count = count }) : Json(data);


Do you see any reason why the grid behaves in that way?

Thank you for your help.


Kind regards
Phil

5 Replies

MF Mohammed Farook J Syncfusion Team December 10, 2018 10:12 AM UTC


Hi Phil, 

Thanks for contacting Syncfusion support. 

We have tried to reproduce the issue with nuget v16.3.0.36. but it is unsuccessful. We have prepared a simple sample based on your query and that can be download from the below link, 
 
 
Still if you facing this  same issue, please share the following details for further assistance, 
 
  1. Full Grid code snippet with code behind.
  2. EJ2 script version.
  3. If possible, try to reproduce the reported issue, in this sample and send back to us.
  4. Video demonstration of this issue.
 
Please get back  to us  for further assistance. 
 
Regards, 
J Mohammed Farook 
 



UN Unknown December 10, 2018 02:34 PM UTC

Thank you for your reply.

I was able to find the culprit:

int count = DataSource.Cast<object>().Count();

In my code, I call this line before operation.Execute(). This causes an endless spinner when searching for values that are not available.
In your example you can move the line mentioned above directly after the declaration of the DataSource IEnumerable, then try filtering for "x" on any column and apply. The endless spinner will appear.

In this thread https://www.syncfusion.com/forums/137144/generic-server-side-pagination-sorting-and-filtering (last reply from Syncfusion) the counting is done before the DataOperations .Execute() method is called.

However, there is another issue that arrises, when counting after the DataOperations .Execute() method has been called.
The pagination will not work anymore.

You can test this by adding the following line in "Index.cshtml" the original sample that you linked in you post:

The grid will now only show 7 results and no additional pages are shown in the pagination.

It seems that the Filter function and the Pagination function and the DataOperations .Execute() method are not compatible with one another.

In the official documentation the server side data operations are often performed in this way:

IEnumerable DataSource = OrdersDetails.GetAllRecords();
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);

Therefore it might be necessary to manually perform all data operations when using them in certain combinations.

Could you please clarify how the data operations should be performed to achieve the desired result?
Should the DataOperations .Execute() method be used at all?



VA Venkatesh Ayothi Raman Syncfusion Team December 11, 2018 10:52 AM UTC

Hi Phil, 

Thanks for the update. 
 
We have found that incorrect count values is returned from server side when we search or filter the value which is not present in the Grid data source. In this case, filter/searched result as empty, so count value should be empty. But in your code example, you are get the count value before the Data operation execution method.  
So it returned total records count always if we filtered record as 2. 

So we suggest you perform the server side operation as like as follows,  
IEnumerable DataSource = OrdersDetails.GetAllRecords(); 
            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); 

In the above code example, we get the count after the Grid actions such as Sorting, filtering and searching. This the proper way to returned the object which holds the property of result and count. 
 
Please let us know if you have any further assistance on this. 
 
Regards, 
Venkatesh Ayothiraman. 



UN Unknown December 12, 2018 12:58 PM UTC

This helped me to implement a working solution.
In the future I will not use the .Execute() method anymore.

Thank you for your help.


MF Mohammed Farook J Syncfusion Team December 13, 2018 07:35 AM UTC

Hi Phil, 
 
Thanks for your update. 
 
We are happy to hear that the provided solution has been resolved your problem. 
 
Please get back to us if you need further assistance. 
 
Regards 
J Mohammed Farook 
 


Loader.
Up arrow icon