Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,18 +1741,19 @@ protected internal async Task ToggleDetailRow( DataGridRowInfo<TItem> rowInfo, D
else if ( DetailRowTrigger is not null )
{
var detailRowTriggerContext = new DetailRowTriggerEventArgs<TItem>( rowInfo.Item );
var detailRowTriggerResult = DetailRowTrigger( detailRowTriggerContext );
var shouldOpenWhenClosed = DetailRowTrigger( detailRowTriggerContext );

if ( !skipDetailRowTriggerType && detailRowTriggerType != detailRowTriggerContext.DetailRowTriggerType )
return;

rowInfo.SetRowDetail( detailRowTriggerResult, detailRowTriggerContext.Toggleable );

if (detailRowTriggerContext.Toggleable)
rowInfo.SetRowDetail(!rowInfo.HasDetailRow && shouldOpenWhenClosed);

if ( rowInfo.HasDetailRow && detailRowTriggerContext.Single )
{
foreach ( var row in Rows.Where( x => !x.IsEqual( rowInfo ) ) )
foreach ( var row in Rows.Where( x => !x.IsEqual( rowInfo ) ) )//close other detail rows
{
row.SetRowDetail( false, false );
row.SetRowDetail( false);
}
}
}
Expand Down Expand Up @@ -3608,6 +3609,8 @@ public IReadOnlyList<DataGridBatchEditItem<TItem>> BatchChanges

/// <summary>
/// A trigger function used to handle the visibility of detail row.
/// Return true if you want the detail row to be visible when row is clicked and detail row is not visible.
/// Doesn't affect the closing behaviro (will be always close on click)
/// </summary>
[Parameter] public Func<DetailRowTriggerEventArgs<TItem>, bool> DetailRowTrigger { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ public DataGridRowInfo( TItem item, IEnumerable<DataGridColumn<TItem>> columns )
/// <summary>
/// Sets the detail row for the current row.
/// </summary>
/// <param name="hasDetailRow">Indicates whether the detail row is present.</param>
/// <param name="toggleable">Indicates whether the detail row can be toggled.</param>
public void SetRowDetail( bool hasDetailRow, bool toggleable )
=> this.hasDetailRow = ( toggleable && !this.hasDetailRow & hasDetailRow ) || ( !toggleable && hasDetailRow );
/// <param name="hasDetailRowNew">Open or close the detail row</param>
public void SetRowDetail( bool hasDetailRowNew )
=> this.hasDetailRow = hasDetailRowNew;

/// <summary>
/// Toggles the visibility of the detail row.
Expand Down
Loading