Hi Jeevakanth thank you for you reply. In my project I'm using MVVM pattern, so to test the grid in order to find the error, I made a clean page using the grid without view model, and the grid works fine, it loads all records when the page is initialized after I add a new record on a different page without any problems.
The problem becomes when I connect the grid to a datasource on a viewmodel, let me put my code here and if yout think you can help me I would really appreciate it.
Clients razor page
@inject ClientsViewModel VM
<SfGrid DataSource="@VM.ClientsList" ID="ClientsGrid" AllowTextWrap="true">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true">
</GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Client.ClientId) HeaderText="Cliente Id" TextAlign="TextAlign.Center" Width="10"></GridColumn>
<GridColumn Field=@nameof(Client.Name) HeaderText="Name" TextAlign="TextAlign.Left" Width="45"></GridColumn>
</GridColumns>
</SfGrid>
@code {
protected override async Task OnInitializedAsync()
{
await VM.InitializeViewModelAsync();
}
}
And this is ViewModel Code
public class ClientsViewModel
{
private IClientRepository ApiClientManager { get; set; }
public List<Client> ClientsList { get; set; }
public ClientsViewModel(IClientRepository ClientRepository)
{
ApiClientManager = ClientRepository;
}
public async Task InitializeViewModelAsync()
{
ClientsList = await ApiClientManager.GetAllClientes(); // Connects to the Api that brings the data
}
}
And in the page that adds the new record after the data is saved on database I navigate to clients page like this
navigationManager.NavigateTo("clients");
When I debug the program, on Clients page after new record is added, the ClientsList has all records, so I dont understand why the grid doesnt show all of them but as I mentiond before if I dont use the ViewModel the grid works perfect.
Thanks