We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unbound row value not updating if not in view

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.


Attachment: UnboundRow_issue_ca6dd4d3.zip

4 Replies

DM Dhanasekar Mohanraj Syncfusion Team October 28, 2022 09:10 AM

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;

private void OnDataGridScroll(object sender, ScrollEventArgs e)

{

    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.


Attachment: UnboundRow_issue_7d10739b.zip


AT Alison Tan November 1, 2022 10:49 PM

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?



DM Dhanasekar Mohanraj Syncfusion Team November 2, 2022 09:08 AM

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.



AT Alison Tan November 3, 2022 08:30 PM

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:

  1. Edit the "Price" value on the 1st item, scroll down to view the updated unbound row (sum)
  2. Scroll back up and edit the 2nd item, click "remove" button twice until the unbound row comes into view

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.


Attachment: UnboundRow_issue_withAddRemoveBtn_6e778a98.zip

Loader.
Live Chat Icon For mobile
Up arrow icon