I've created a simple unbound row which display the sum of all integers in a column. When I edit the value in the cell with the unbound row in view, the sum in the unbound row rerenders as normal. But when I scroll up to edit the cell on top, while the unbound row is not shown within the data grid view, it won't rerender or update the new sum value.
Hi Alison Tan,
We have checked the reported issue on our end. In that, the reported issue
occurs because of unbound row does not update properly. However, you can
overcome the reported issue by invalidating the unbound row programmatically
shown below,
|
this.sfDataGrid1.TableControl.Scroll += OnDataGridScroll; this.sfDataGrid1.CurrentCellEndEdit +=
sfDataGrid1_CurrentCellEndEdit; { if (sfDataGrid1.TableControl.ScrollRows.LastBodyVisibleLineIndex == this.sfDataGrid1.ResolveUnboundRowToRowIndex(sfDataGrid1.UnboundRows[0])) { var rowIndex = this.sfDataGrid1.ResolveUnboundRowToRowIndex(sfDataGrid1.UnboundRows[0]); var column = this.sfDataGrid1.Columns["Price"]; this.sfDataGrid1.InValidateUnboundRow(sfDataGrid1.UnboundRows[0], true); this.InvalidateRowRectangle(rowIndex, false); } }
void sfDataGrid1_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e) { var rowIndex = this.sfDataGrid1.ResolveUnboundRowToRowIndex(sfDataGrid1.UnboundRows[0]); this.sfDataGrid1.InValidateUnboundRow(sfDataGrid1.UnboundRows[0], true); this.InvalidateRowRectangle(rowIndex, false);
}
internal void InvalidateRowRectangle(int rowIndex, bool isClipped) { var rowRectangle = this.sfDataGrid1.TableControl.GetRowRectangle(rowIndex, isClipped); this.sfDataGrid1.TableControl.Invalidate(rowRectangle); } |
We have modified the attached sample based on your scenario.
Please have a look at this and revert us if you need further assistance with
this.
Regards,
Dhanasekar M.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Thanks, the trick is working. However, since you mentioned that this issue is caused by unbound row not updated properly, would it be considered as a bug? If so, is there any intention to fix it?
No, the reported scenario is
not an issue. By default, if you need to change the unbound row values In the
run time you should update this manually. For more information related to
refreshing the unbound row at run time, please refer to the below user guide
documentation link,
UG Link: https://help.syncfusion.com/windowsforms/datagrid/unboundrow#refreshing-the-unbound-rows-at-runtime
In your scenario, the unbound row is present out of view. So, you need to
invalidate (Update) the unbound row values while performing the scrolling. For
that, we have provided a solution to overcome the reported issue.
The workaround provided is working only when the scroll event is invoked. But in my case, there're two buttons to add/remove items from the datagrid (please refer the sample attached). When the unbound row at the bottom comes into view by removing items from the top, rather than scrolling down to view it, at one point the value shown wouldn't be updated.
To reproduce:
Result: The value shown in unbound row remains as the value in Step 1 and it will
only be updated when the scrollbar is clicked.