Hi,
I noticed that when I call GetFilteredRecordsAsync() on a grid when no grouping is done, I get a List<T> where T is TValue specified for the grid (i.e if I have a SfGrid<Person> I obtain a List<Person>), and that's fine.
If I call GetFilteredRecordsAsync() when record are grouped, I obtain instead a List<Syncfusion.Blazor.Data.Group<T?> where T? could be my model type (i.e. Person) or another Syncfusion.Blazor.Data.Group if multiple grouping levels exists.
Is there an easy way to get the plain List of my model type when one or more grouping level are currently present in my grid?
Hi Roberto,
Greetings from Syncfusion support.
We suggest you to check this by using the GetCurrentViewRecordsAsync method of Grid. You can fetch the list of data available in grid’s current view using this method. Please refer the codes below,
|
public async Task OnClick() { var data = await grid.GetCurrentViewRecordsAsync(); }
|
Please check your requirement using this method and if you still face difficulties then kindly get back to us with a detailed explanation of your exact requirement for us to proceed further.
Regards,
Renjith R
Hi Renjit,
I checked your suggested method, but it's not suitable for my needs because in a paginated grid it only returns record from the currently visible page, while GetFilteredRecordsAsync() correctly returns items from all pages (except filtered out records) but when records are grouped the result is not a plain List<TValue> but a List<Group<TValue>> if data is grouped with a single level, or a further nested List if data is grouped with more levels.
Is there a way to obtain the plain List<TValue> from such results?
Thanks
Roberto
Hi Roberto,
We are currently checking this scenario from our side. We will update you further within two business days on or before April 25, 2022.
Until then we appreciate your patience.
Regards,
Renjith R
Hi Roberto,
Thanks for the patience.
We would like to inform that we can get filtered data as an list by using the below highlighted changes and we can store the data in to required format as per our need. Kindly check the attached code snippet for your reference.
|
public async Task GetData() {
var filteredRecords = await Grid.GetFilteredRecordsAsync(); List<string> FilteredItems = new List<string>();
foreach (Group<Order> groupData in filteredRecords as List<Group<Order>>) {
List<Order> Data = groupData.Items as List<Order>; // we can store the data here as an list.
//FilteredItems.Add(groupData.Items.ToString());
}
} |
Kindly get back to us if you have further queries.
Regards,
Monisha
Thanks Monisha, that works nicely.
Hi Roberto,
Thanks for your update. Please get back to us if you need further assistance.
Regards,
Renjith R