<SfTreeGrid @ref="treeGridHiCoSwcChildren" ……….>
<TreeGridEvents TValue="HiCoSwc" RowSelected="GetSelectedSwcPartRow" />
……………..
<TreeGridColumns>
…………………….
</TreeGridColumns>
</SfTreeGrid>
@code{
……………………..
SfTreeGrid<HiCoSwc> treeGridHiCoSwcChildren;
public async void GetSelectedSwcPartRow(RowSelectEventArgs<HiCoSwc> args)
{
var temp = await this.treeGridHiCoSwcChildren.GetSelectedRecords();
// do your stuff
}
}
|
<SfGrid @ref="DefaultGrid" AllowPaging="true" DataSource="@Orders" AllowSorting="true"AllowSelection="true"
AllowFiltering="true">
<GridEvents RowSelected="RowSelectHandler" RowDeselected="RowDeselectHandler" TValue="Order"></GridEvents>
<GridEditSettings AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridSelectionSettings EnableToggle="true" PersistSelection="true"></GridSelectionSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true"TextAlign="@TextAlign.Center" Width="80"></GridColumn>
. . .
<GridColumn Type="ColumnType.CheckBox" Width="40"></GridColumn>
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> DefaultGrid;
. . .
public async void RowSelectHandler(RowSelectEventArgs<Order> args)
{
//all the selected records are getting properly
var SelectedRecords = await DefaultGrid.GetSelectedRecords();
var RowCountSelected = SelectedRecords.Count();
}
public async void RowDeselectHandler(RowDeselectEventArgs<Order> args)
{
//RowDeselected – it will show the remaining selected records while deselecting(deselected one in not countable)
var SelectedRecords = await DefaultGrid.GetSelectedRecords();
var RowCountSelected = SelectedRecords.Count();
}
} |
………………….
<SfTreeGrid @ref="treeGridHiCoSwcChildren" ID="targetSwc" DataSource="@HiCoSwcChildrenCollection" AllowSelection="true" TValue="HiCoSwc" ParentIdMapping="@nameof(HiCoSwc.ParentID)>
…………………………..
</SfTreeGrid>
………………………..
@code{
SfTreeGrid<HiCoSwc> treeGridHiCoSwcChildren;
public async void GetSelectedRow(RowSelectEventArgs<HiCoSwc> args)
{
var temp = await treeGridHiCoSwcChildren.GetSelectedRecords(); // store the selected records in a variable here
Console.Write("#### selected items: "); //show the selected records count here
Console.WriteLine(temp.Count); // get the selected records count here
} } |