Hi Pawel,
Greetings from Syncfusion.
Query: “ is there any method or way to get all
sorted and filtered data by SfGrid, not only shown at the moment on the
screen?”
We suggest you to use GetFilteredRecordsAsync
method to get all the filtered data in DataGrid and also we would like to
inform you that currently, we do not have built-in support to directly fetch
all sorted data from the DataGrid. However, we have an alternative solution
that can help you achieve your requirement.
To obtain all the sorted data, we recommend accessing the
Grid instance and retrieving the data from its DataSource property. Once you
have access to the data, you can utilize LINQ queries to apply sorting
operations as per your needs.
Below is a code snippet that provides additional information
on how you can accomplish this:
|
<SfButton @onclick="Click">Click</SfButton>
<SfGrid DataSource="@Orders" @ref="Grid" AllowMultiSorting="true" AllowSorting="true" AllowFiltering="true" AllowPaging="true">
<GridColumns>
...
</GridColumns>
</SfGrid>
@code {
SfGrid<Order> Grid { get; set; }
public List<Order> Orders {
get; set; }
public void Click()
{
// To get filtered records
var c =
Grid.GetFilteredRecordsAsync();
var b = Grid.SortSettings; // perform orderby or
orderbydescending based on the sort order
var sortedData =
Grid.DataSource.OrderByDescending(x => x.OrderID).ToList();
}
}
|
Please get back to us if you face any difficulties.
Regards,
Monisha