When using grid customadapter menu filter, on input following error occurs.
<EjsGrid TValue="BusinessSectorList" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true">
<EjsDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></EjsDataManager>
<GridFilterSettings Type="Syncfusion.EJ2.Blazor.Grids.FilterType.Menu" ></GridFilterSettings>
<GridPageSettings PageSize="8"></GridPageSettings>
<GridColumns>
<GridColumn Field=@nameof(BusinessSectorList.Id) IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn>
<GridColumn Field=@nameof(BusinessSectorList.Name) Width="150"></GridColumn>
</GridColumns>
</EjsGrid>
@code {
public class BusinessSectorList
{
public int Id { get; set; }
public string Name { get; set; }
}
// Implementing custom adaptor by extending the DataAdaptor class
public class CustomAdaptor : DataAdaptor
{
private MyContext db = new MyContext();
// Performs data Read operation
public override object Read(DataManagerRequest dm, string key = null)
{
IQueryable<BusinessSectorList> DataSource = db.BusinessSector.Select(x => new BusinessSectorList
{
Id = x.Id,
Name = x.Name
});
if (dm.Search != null && dm.Search.Count > 0)
{
// Searching
DataSource = DataOperations.PerformSearching(DataSource, dm.Search);
}
if (dm.Sorted != null && dm.Sorted.Count > 0)
{
// Sorting
DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0)
{
// Filtering
DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
int count = DataSource.Cast<BusinessSectorList>().Count();
if (dm.Skip != 0)
{
//Paging
DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);
}
if (dm.Take != 0)
{
DataSource = DataOperations.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? new DataResult() { Result = DataSource.ToList(), Count = count } : (object)DataSource.ToList();
}
}