Record rowState as Updated when row is updated in bound spread

Posted by: aslyon-getmail-no on 8 September 2017, 1:34 pm EST

  • Posted 8 September 2017, 1:34 pm EST

    Hi,


     I have a spread bound to a dataTable. My problem is that the rowState of a row is not set to Modified when I make changes in a cell, neither if I move to another cell. It seems I have to move to another row for the edited row to be marked Modified. I need to check this flag and I execute the following code:



    fpSampleData.StopCellEditing()


    Dim dt As DataTable


    dt= fpSampleData.DataSource


    dt.Rows.Item(mySmplSheet.ActiveRowIndex).EndEdit()


    For Each aRow In dt.Rows



    If aRow.RowState = DataRowState.Modified Then


    ...............


    End If


    Next aRow


     This if statement doesn't seem to execute its code if I only make a change in one cell. I thought the above EndEdit code should fix this, but is there anything else smart that I have overlooked?


    Anne

  • Replied 8 September 2017, 1:34 pm EST

    Anne,


    The call to EndEdit on the DataRow is what is needed to mark the RowState correctly. Are you making sure to call the AcceptChanges method on the DataTable after binding to the Spread to mark all rows to UnChanged?

  • Replied 8 September 2017, 1:34 pm EST

    When I bind the datatable of course all rows are unChanged as I have just read the data from the database. The user makes his changes and selects a menu item which fires my function. Each time the function that looks for all the Modified rows, is called, I do an AcceptChanges after the loop has finished. But very often no rows have Modified flag set, even if the user has made a change in a cell, or if the user has changed several rows, all but the last one are flagged as Modified (which supports my supsicion that only when I change row si the Modified flag actually set). EndEdit seems to have no effect...?
  • Replied 8 September 2017, 1:34 pm EST

    Hello,


    Could you post a small zipped project reproducing this issue for us to debug. When you make a change in the Spread and cause the DataRow that is changed to have it's EndEdit called, then the RowState will change if there is no errors. You can get this EndEdit to be called by you programatically calling it or clicking off the row. You can check if any errors are causing this not to work by putting a break point in the Error and EditError events of the Spread.


    When you loop all the rows of the bound DataSource, what are the RowState's of each row? Have you checked them to see what they are set to?

  • Replied 8 September 2017, 1:34 pm EST

    Scott,


    thanks for your input. As I was trying to explain to you what was going on I figured out what was happening. My Spread is sorted ascending by 2 columns. If the sort order was the same as the row order in the bound DataTable everyting worked fine, but not if the Spread sorted the rows in a different order.


    Then I realized that the call to EndEdit, dt.Item(mySmplSheet.ActiveRowIndex).EndEdit(), refers to the ActiveRow, 1, on the spread, while the same row has index 0 in the DataTable. Hence the wrong row in the DataTable got the EndEdit call. I guess there is no way of finding which row number in the DataTable that actually need to have EndEdit called when order of rows doesn't correspond?


    So if I loop through my whole dataSource and call EndEdit for each and every row, then the RowState is updated the way it should.


    I understand you had your reasons to not support StopCellEditing anymore, but that command always seemed to do the trick...


    Thanks anyway, I am grateful for Farpoint's fantastic support team!

  • Replied 8 September 2017, 1:34 pm EST

    Hello,


    We did use to update the bound DataSource on every cell change, but this became a large performance hit for customers making constant changes to cells in the Spread.We then decided to update on the row change, like the Grid controls that you can bind to the DataSource. To find the correct DataRow to call the EndEdit on, you can use the GetModelRowFromViewRow and GetDataRowFromModelRow methods of Spread to find where the edited row is.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels