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 Remote Data

Hi,

Im using the datagrid URL Adaptor as datasource, however following the example provided, it first retrieved ALL rows of data 

public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm)
        {
            IEnumerable Data = OrderRepository.GetAllRecords();            
            Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();
                       if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
            {
                Data = operation.PerformSorting(Data, dm.Sorted);
            }
            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {
                Data = operation.PerformWhereFilter(Data, dm.Where, dm.Where[0].Operator);
            }
                 int count=Data.AsQueryable().Count();
            if (dm.Skip != 0)
            {
                Data = operation.PerformSkip(Data, dm.Skip);
            }
            if (dm.Take != 0)
            {
                Data = operation.PerformTake(Data, dm.Take);
            }
                   return Json(new { result = Data, count = count }, JsonRequestBehavior.AllowGet);
        }
I found this to be inefficient since when the data gets too large it takes seconds to retrieve the data
is there anyway to perform the data manipulation without having to retrieve the entire dataset?
I tried using IQueryable<T> as the data but this returns error

There is already an open DataReader associated with this Connection which must be closed first.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: MySql.Data.MySqlClient.MySqlException: There is already an open DataReader associated with this Connection which must be closed first.



1 Reply

SA Saravanan Arunachalam Syncfusion Team April 17, 2017 06:53 AM UTC

Hi Andrias, 
Thanks for contacting Syncfusion’s support. 
We have analyzed your query, the UrlAdaptor returns data to the Grid control after perform the Grid operations such as paging, filtering and sorting. If we are not perform paging (Skip and Take), it will return all the records to the Grid from server. So, please ensure whether you have enabled the allowPaging on your project to perform ondemand paging and also ensure Skip and Take value on server after enable the paging. Please refer to the below code example, screenshot and online documentation link. 
@(Html.EJ().Grid<object>("FlatGrid") 
        .AllowPaging() 
            .Datasource(ds=> ds.URL("DataSource").Adaptor(AdaptorType.UrlAdaptor)) 
           . . . 
        ) 
 
 
We have also created a sample that can be downloaded from the below link, 
Regards, 
Saravanan A. 


Loader.
Up arrow icon