Replies: 1 comment
-
The only built-in methods to capture the sequence in which items are selected --that I'm aware of -- is via the Focus and Click events such as <FluentDataGrid Items="@_people.AsQueryable()"
TGridItem="Person"
OnRowClick="HandleRowClick">
<SelectColumn TGridItem="Person"
SelectMode="DataGridSelectMode.Multiple"
SelectFromEntireRow="true"
Property="@(e => e.Selected)"/>
<PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
<PropertyColumn Property="@(p => p.Name)" Sortable="true" />
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
</FluentDataGrid>
<h4>Selected People (in order of selection):</h4>
<ul>
@foreach (var row in selectedRows)
{
<li>@row?.Item?.Name</li>
}
</ul>
@code {
record Person(int PersonId, string Name, DateOnly BirthDate, bool Selected = false);
private readonly static Person[] _people = new[]
{
new Person(10895, "Jean Martin", new DateOnly(1985, 3, 16)),
new Person(10944, "António Langa", new DateOnly(1991, 12, 1)),
new Person(11203, "Julie Smith", new DateOnly(1958, 10, 10)),
new Person(11205, "Nur Sari", new DateOnly(1922, 4, 27)),
new Person(11898, "Jose Hernandez", new DateOnly(2011, 5, 3)),
new Person(12130, "Kenji Sato", new DateOnly(2004, 1, 9)),
};
private List<FluentDataGridRow<Person>> selectedRows = new();
private void HandleRowClick(FluentDataGridRow<Person> row)
{
if (selectedRows.Contains(row))
{
selectedRows.Remove(row);
}
else
{
selectedRows.Add(row);
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all!
I'm trying to fix a bug in my app:
I've implemented a data grid row selection with ctrl and shift modifier. Anyway, in order to make it works better, I need to get the DataGrid data as the user have order them.
If so I'm not able to determine the IndexOf positions of current selected record, as it would be different!
Is there I can do to returns me the data reordered as the user need?
Beta Was this translation helpful? Give feedback.
All reactions