Hi Edward,
Thanks for contacting Syncfusion support.
Query: “The sample code works fine but if I enable AllowSorting="true" the grid does not sort. Is there additional changes needed to get sorting to work?”
Yes, while using CustomAdaptor data operations like filtering, sorting, searching, etc. needs to be handled in the ReadAsync method of the CustomAdaptor. In that Github sample, we have used custom adaptor to bind datasource to Grid component using Dapper ORM. Since the sample explains the CRUD operations, we have not handled the data operations in it.
Kindly modify the ReadAsync method as below in BugDataAdaptor.cs to perform DataOperation in Grid.
|
public override async Task<object> ReadAsync(DataManagerRequest dm, string key = null)
{
IEnumerable<Bug> bugs = await _dataLayer.GetBugsAsync();
if (dm.Search != null && dm.Search.Count > 0)
{
// Searching
bugs = DataOperations.PerformSearching(bugs, dm.Search);
}
if (dm.Sorted != null && dm.Sorted.Count > 0)
{
// Sorting
bugs = DataOperations.PerformSorting(bugs, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0)
{
// Filtering
bugs = DataOperations.PerformFiltering(bugs, dm.Where, dm.Where[0].Operator);
}
int count = bugs.Cast<Bug>().Count();
if (dm.Skip != 0)
{
//Paging
bugs = DataOperations.PerformSkip(bugs, dm.Skip);
}
if (dm.Take != 0)
{
bugs = DataOperations.PerformTake(bugs, dm.Take);
}
return dm.RequiresCounts ? new DataResult() { Result = bugs, Count = count } : count;
}
|
Refer our UG documentation for your reference
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan