Entire grid changes when a single cell is edited.
When I edit a cell in a data grid, the entire grid changes. Each row in the grid is replaced by the row of the cell that was edited. What could be causing that effect?
@using static PorfolioAnalysis.Components.Class_files.Portfolio
<div class="row p-2 thistable">
<SfGrid DataSource="@PortfolioAccounts" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" AllowPaging="false" Width="100%">
<GridEditSettings AllowAdding="true"
AllowDeleting="true"
AllowEditing="true"
ShowAddNewRow="false">
</GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(PortfolioAccount.Id) HeaderText="ID" TextAlign="TextAlign.Center" Width="25" IsPrimaryKey="true"></GridColumn>
<GridColumn Field=@nameof(PortfolioAccount.Owner) HeaderText="Owner" TextAlign="TextAlign.Center" Width="25" AllowEditing="true"></GridColumn>
<GridColumn Field=@nameof(PortfolioAccount.AccountName) HeaderText="Account Name" TextAlign="TextAlign.Center" Width="50" AllowEditing="true"></GridColumn>
<GridColumn Field=@nameof(PortfolioAccount.Balance) HeaderText="Balance" TextAlign="TextAlign.Center" Width="50" Format="C0" AllowEditing="true" ></GridColumn>
<GridColumn Field=@nameof(PortfolioAccount.Taxed) HeaderText="Taxable" TextAlign="TextAlign.Center" Width="50" AllowEditing="true"></GridColumn>
<GridColumn Field=@nameof(PortfolioAccount.AccountType) HeaderText="Type" TextAlign="TextAlign.Center" Width="50" AllowEditing="true"></GridColumn>
<GridColumn Field=@nameof(PortfolioAccount.LastUpdate) HeaderText="Updated" TextAlign="TextAlign.Center" Width="50" AllowEditing="true"></GridColumn>
<GridColumn Field=@nameof(PortfolioAccount.AccountNumber) HeaderText="Acct #" TextAlign="TextAlign.Center" Width="50" AllowEditing="true"></GridColumn>
</GridColumns>
</SfGrid>
<br />
<div class="d-flex flex-row m-2 align-content-center">
<h5 class="align-content-center">Click on Update before saving.</h5>
<button class="btn btn-primary ms-2" @onclick="@(()=> TableChanged.InvokeAsync(PortfolioAccounts))"> Save</button>
</div>
</div>
@code {
[Parameter]
public List<PortfolioAccount> PortfolioAccounts { get; set; } = new List<PortfolioAccount>();
[Parameter]
public EventCallback<List<PortfolioAccount>> TableChanged { get; set; }
}
Hi Dennis Imbro,
We have bound the data source to the provided code snippet and validated it from our end. The mentioned issue could not be reproduced.
However, we suspect that the PrimaryKey column values might not be unique in your case. If the values in the primary key column are not unique, it can cause changes to affect multiple records unexpectedly.
We kindly request you to ensure that unique values are bound to the PrimaryKey column and check if the issue persists.
Sample Ensured from our End:
If the reported issue still reproduced, then kindly share the below details to validate further at our end.
- Please provide a simple issue replicating sample or try to modify the above-mentioned sample.
- Share us the video demonstration of the reported issue.
The above requested detail will be very helpful for us to validate the reported issue at our end.
Regards,
Sanjay Kumar Suresh
Thanks for the quick reply. Non-unique primary keys was indeed the problem.
Hi Dennis Imbro,
We are happy to hear that the provided solution was helpful. Please get back to us if you need any other assistance.
Regards,
Sanjay Kumar Suresh
- 3 Replies
- 2 Participants
-
DI Dennis Imbro
- Apr 20, 2025 07:18 PM UTC
- Apr 23, 2025 05:32 AM UTC