Skip to content

Commit

Permalink
DataGrid: DataGridSelectEdit | Always refresh selectItems if Data cou…
Browse files Browse the repository at this point in the history
…nt has changed (#5868)

* DataGridSelectEdit | Always refresh selectItems if Data count has changed

* Revert "DataGridSelectEdit | Always refresh selectItems if Data count has changed"

This reverts commit 9924d77.

* DataGridSelectEdit | Always refresh selectItems if Data count has changed

* cleanup directives

* cleanup directives

* remove spaces from directives
  • Loading branch information
David-Moreira authored Nov 25, 2024
1 parent 3ac026e commit 25e6d64
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 )
Expand All @@ -51,8 +56,7 @@ protected override void OnInitialized()
selectItems.Add( new( text, value, disabled ) );
}
}

base.OnInitialized();
base.OnParametersSet();
}

private void OnSelectedValueChanged( object value )
Expand Down Expand Up @@ -92,7 +96,6 @@ protected override async Task OnAfterRenderAsync( bool firstRender )
{
await Focus();
}

}
}
await base.OnAfterRenderAsync( firstRender );
Expand All @@ -115,6 +118,7 @@ public async Task Select()
[CascadingParameter] public DataGrid<TItem> ParentDataGrid { get; set; }

[Inject] public IIdGenerator IdGenerator { get; set; }

/// <summary>
/// Gets or sets the <see cref="IJSUtilitiesModule"/> instance.
/// </summary>
Expand Down

0 comments on commit 25e6d64

Please sign in to comment.