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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Exception When using complex filtering + UrlAdaptor

Thread ID:

Created:

Updated:

Platform:

Replies:

150184 Dec 24,2019 03:37 PM UTC Dec 30,2019 10:55 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: DataGrid
Mohammad M Alshehri
Asked On December 24, 2019 03:37 PM UTC

I'm getting this error:
NullReferenceException: Object reference not set to an instance of an object.

Syncfusion.EJ2.Base.QueryableOperation.GetColumnType<T>(IQueryable<T> dataSource, string filterString, Type type)

Please help

This is my code:

private IQueryable<ContractListVM> GetContractsQuery()
{
            return _contractRepository.GetContracts()
                .OrderByDescending(x => x.CreatedOn)
                .Select(contract => new ContractListVM
                {
                    ContractId = contract.ContractId,
                    ContractAmount = contract.ContractAmount,
                    ContractStatus = Enumeration.FromValue<ContractStatusEnum>(contract.ContractStatusId).Name,
                    CreatedOn = contract.CreatedOn.ToString("dd-MM-yyyy"),
                    ExpirationDate = contract.ExpirationDate.Value.ToString("s"),

                }).AsQueryable();
}


public async Task<IActionResult> UrlDatasource([FromBody]DataManagerRequest dm)
        {
            var query = GetContractsQuery();
            var operation = new QueryableOperation();
            var count = query.Count();


            if (dm.Search != null && dm.Search.Count > 0)
            {
                query = operation.PerformSearching(query, dm.Search);  //Search
            }
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
            {
                query = operation.PerformSorting(query, dm.Sorted);
            }
            if (dm.Where != null && dm.Where.Any()) //Filtering
            {
                foreach (var whereFilter in dm.Where)
                {
                    if (whereFilter.IsComplex)
                    {
                        foreach (var whereFilterPredicate in whereFilter.predicates)
                        {
                            query = operation.PerformFiltering(query, dm.Where, whereFilterPredicate.Operator);
                        }
                    }
                    else
                    {
                        query = operation.PerformFiltering(query, dm.Where, dm.Where.First().Operator);
                    }
                }
            }

            var str = new List<string>();

            if (dm.Aggregates != null)
            {
                str.AddRange(dm.Aggregates.Select(t => t.Field));
            }

            var aggregate = operation.PerformSelect(query, str);

            if (dm.Skip != 0)
            {
                query = operation.PerformSkip(query, dm.Skip);   //Paging
            }
            if (dm.Take != 0)
            {
                query = operation.PerformTake(query, dm.Take);
            }

            var result = await query.ToListAsync();

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



Ui code: 

<ejs-grid id="ContractsGrid"
          allowPaging="true"
          allowSorting="true"
          allowFiltering="true"
          allowMultiSorting="true"
          showColumnChooser="true"
          allowResizing="true"
          toolbar="@(new List<string>() { "Search", "ExcelExport", "ColumnChooser" })"
          allowExcelExport="true"
          toolbarClick="toolbarClick"
          excelExportComplete="excelExportComplete">
    <e-grid-pagesettings pageSize="20"></e-grid-pagesettings>
    <e-data-manager url="@Url.Action("UrlDatasource", "ContractList")" adaptor="UrlAdaptor"></e-data-manager>
    <e-grid-filtersettings type="Excel" mode="Immediate"></e-grid-filtersettings>


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On December 30, 2019 10:55 AM UTC

Hi Mohammed, 
  
Thanks for your update. 
  
We have considered this as a usability feature improvement “Problem with DataOperations when bind IQueryable data to Grid”, and logged a task for the same. 
  
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.  
  
  
We will include this feature in our any upcoming release. Until then we suggest you to bind List values to Grid to overcome the problem you are facing. 
  
Regards, 
Seeni Sakthi Kumar S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon