- Home
- Forum
- ASP.NET Core - EJ 2
- Exception When using complex filtering + UrlAdaptor
Exception When using complex filtering + UrlAdaptor
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>
SIGN IN To post a reply.
1 Reply
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
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
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
MM Mohammad M Alshehri
- Dec 24, 2019 03:37 PM UTC
- Dec 30, 2019 10:55 AM UTC