diff --git a/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs b/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs index 698032a4f2..fd2fc9d501 100644 --- a/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs +++ b/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs @@ -22,6 +22,7 @@ private class SelectItem public string Text { get; private set; } public object Value { get; private set; } public bool Disabled { get; private set; } + public SelectItem( string text, object value, bool disabled ) { Text = text; @@ -39,8 +40,12 @@ public SelectItem( string text, object value, bool disabled ) protected override void OnInitialized() { elementId = IdGenerator.Generate; + base.OnInitialized(); + } - if ( Column.Data is not null ) + protected override void OnParametersSet() + { + if ( Column?.Data is not null && selectItems?.Count != Column.Data.Count() ) { selectItems = new(); foreach ( var item in Column.Data ) @@ -51,8 +56,7 @@ protected override void OnInitialized() selectItems.Add( new( text, value, disabled ) ); } } - - base.OnInitialized(); + base.OnParametersSet(); } private void OnSelectedValueChanged( object value ) @@ -92,7 +96,6 @@ protected override async Task OnAfterRenderAsync( bool firstRender ) { await Focus(); } - } } await base.OnAfterRenderAsync( firstRender ); @@ -115,6 +118,7 @@ public async Task Select() [CascadingParameter] public DataGrid ParentDataGrid { get; set; } [Inject] public IIdGenerator IdGenerator { get; set; } + /// /// Gets or sets the instance. /// diff --git a/Source/Extensions/Blazorise.DataGrid/_DataGridDetailRow.razor.cs b/Source/Extensions/Blazorise.DataGrid/_DataGridDetailRow.razor.cs index 46368f1bf6..a85039e168 100644 --- a/Source/Extensions/Blazorise.DataGrid/_DataGridDetailRow.razor.cs +++ b/Source/Extensions/Blazorise.DataGrid/_DataGridDetailRow.razor.cs @@ -14,7 +14,7 @@ protected bool HasCommandColumn => Columns.Any( x => x.ColumnType == DataGridColumnType.Command ); protected int ColumnSpan - => Columns.Count - ( HasCommandColumn && !ParentDataGrid.Editable ? 1 : 0 ); + => Columns.Where( x => x.Displayable ).Count() - ( HasCommandColumn && !ParentDataGrid.Editable ? 1 : 0 ); /// /// Item associated with the data set.