diff --git a/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs b/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs index 698032a4f2..e4ab7780c7 100644 --- a/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs +++ b/Source/Extensions/Blazorise.DataGrid/_DataGridCellSelectEdit.razor.cs @@ -1,8 +1,11 @@ #region Using directives +using System.Collections.Generic; +using System; using System.Linq; using System.Threading.Tasks; using Blazorise.Modules; using Microsoft.AspNetCore.Components; +using Blazorise.Extensions; #endregion namespace Blazorise.DataGrid; @@ -39,8 +42,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 +58,7 @@ protected override void OnInitialized() selectItems.Add( new( text, value, disabled ) ); } } - - base.OnInitialized(); + base.OnParametersSet(); } private void OnSelectedValueChanged( object value )