Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1125
Wingrid Checkboxes and Cancelling from BeforeCellUpdate
posted

Hi

We have some code that performs an action as soon as the user ticks a field in a grid. 

I'm forcing the update to happen as soon as the cell is ticked using:

    Private Sub LocalityDRLUltraGrid_CellChange(sender As Object, e As CellEventArgs) Handles LocalityDRLUltraGrid.CellChange
        If e.Cell.Column.Key = "IsCurrentOption" Then
            e.Cell.Row.Update()
        End If
    End Sub

And allowing the user to cancel the action with this code:

    Private Sub LocalityDRLUltraGrid_BeforeCellUpdate(sender As Object, e As BeforeCellUpdateEventArgs) Handles LocalityDRLUltraGrid.BeforeCellUpdate
        Select Case e.Cell.Column.Key
            Case "IsCurrentOption"
                If e.NewValue = False Then
                    e.Cancel = (MessageBox.Show("Marking a locality as non-current will automatically mark all associated GP practices as non-current.  Do you wish to continue?", _
                                               "Mark locality non-current", MessageBoxButtons.YesNo) = DialogResult.No)
                End If
        End Select
    End Sub

This very nearly works perfectly, the only glitch is that if the user chooses to cancel the update the checkbox is still un-checked.  This is only a UI thing, the value in the underlying object is correctly unchanged and as soon as the the user moves cell/row the cell then flicks back to being checked again.  

Is this expected behaviour?   Is there anyway to force the cell to reload it's value from the datasource when the change is cancelled (without reloading the entire grid)?

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Tom,

    Frankly, I'm not sure if this is a bug or not. The cancel operation is working correctly, but the display isn't updating. It might just be because the cell is still active and in edit mode.

    If you want, I can ask Infragistics Developer Support to write this up for developer review, but even if this is a bug, I'm not sure it's something that could be fixed without a large potential for breakage. So the easiest thing might be for you to work around it. I found a pretty simple and easy workaround:


        Private Sub LocalityDRLUltraGrid_BeforeCellUpdate(sender As Object, e As BeforeCellUpdateEventArgs) Handles LocalityDRLUltraGrid.BeforeCellUpdate
            Select Case e.Cell.Column.Key
                Case "Boolean 1"
                    If e.NewValue = False Then
                        e.Cancel = (MessageBox.Show("Marking a locality as non-current will automatically mark all associated GP practices as non-current.  Do you wish to continue?", _
                                                   "Mark locality non-current", MessageBoxButtons.YesNo) = DialogResult.No)
                        If (e.Cancel) Then
                            e.Cell.EditorResolved.Value = True
                        End If
                    End If

            End Select
        End Sub

Reply Children