I am trying to create a general grid to save the grid configuration by database. But doing tests, when I inject the saved settings, it does not apply them to the grid. It doesn't give any errors either so I'm a bit lost. They are saved perfectly and when obtained through JS they are also fine, but when you pass them to This.settings nothing applies. Here is the code:
public class RadzenDataGridPersonal<TItem> : RadzenDataGrid<TItem> where TItem : class, new()
{
public RadzenDataGridPersonal() : base()
{
this.GridLines = Radzen.DataGridGridLines.Both;
this.PageSize = 10;
this.ShowPagingSummary =true;
this.AllowFiltering = true;
this.AllowSorting = true;
this.AllowPaging = true;
this.AllowColumnReorder = true;
this.SettingsChanged= EventCallback.Factory.Create<DataGridSettings>(this, OnLoadData);
}
protected override async Task OnInitializedAsync()
{
//await LoadStateAsync();
}
private async Task OnLoadData(DataGridSettings args)
{
await JSRuntime.InvokeVoidAsync("window.localStorage.setItem", "SettingsLoadData", JsonSerializer.Serialize<DataGridSettings>(args));
}
private async Task LoadStateAsync()
{
var result = await JSRuntime.InvokeAsync<string>("window.localStorage.getItem", "SettingsLoadData");
if (!string.IsNullOrEmpty(result) && result != "null")
{
this.Settings = JsonSerializer.Deserialize<DataGridSettings>(result);
StateHasChanged();
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await LoadStateAsync();
}
}
}