Syncfusion.EJ2.Base.QueryableOperation.GetColumnType<T>(IQueryable<T> dataSource, string filterString, Type type)
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);
}
<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>