WPF C1DataGrid sort and delete event issue

Posted by: sebastian-jn.k on 4 October 2023, 8:22 pm EST

    • Post Options:
    • Link

    Posted 4 October 2023, 8:22 pm EST - Updated 5 October 2023, 12:07 am EST

    WPF C1DataGrid sort/filter and delete event issue

    assembly version 4.6.20222.770

    hello,

    strange behavior detected if sort a column and rename content.

    The C1DataGrid fires a ‘RowsDeleted’ event.

    We use this event for ‘real’ delete actions so we get a inconsistent state.

    Reproducible:

    -set breakpoint at ‘RowsDeleted’ event

    -click column header for sort

    -Rename ‘A’ to 'Z ( ‘RowsDeleted’ event should triggered)

    Edit:

    second way to trigger delete event with filter:

    -set breakpoint at ‘RowsDeleted’ event

    -click column filter, filter only ‘A’

    -Rename ‘A’ to ‘Z’ ( ‘RowsDeleted’ event should triggered)

    Example attachted.

    OrderDeleteProb.zip

    Regards

  • Posted 5 October 2023, 10:24 pm EST - Updated 5 October 2023, 10:29 pm EST

    Hi Sebastian,

    Thanks for providing the sample application.

    This is the desired behavior of the C1DataGrid control.

    I. RowsDeleted event fired after renaming ‘A’ to ‘Z’ on a sorted column: In the attached sample when ‘A’ is renamed to ‘Z’ on the sorted column, datagrid internally removes the row containing ‘A’ and inserts the updated row according to its order in the grid. The event will not be fired if you rename ‘A’ to some other string(say ‘C’) that does not change its order in the sorted grid.

    II. RowsDeleted event fired after renaming ‘A’ to ‘Z’ in a filtered grid: Since the updated row does not satisfy the filter condition, datagrid internally removes that row. Therefore RowsDeleted event gets fired.

    If you filter the grid based on the condition “Contains A” and rename ‘A’ to ‘Ab’, RowsDeleted event does not get fired.

    We request you explain you use-case scenario and implementation of RowsDeleted event in a bit more detail, so that we can check if there is a possible workaround available to achieve the desired behavior.

    Thanks & Regards,

    Aastha

  • Posted 9 October 2023, 1:16 am EST

    From C1DataGrid Documentation:

    DeletingRows Event (C1DataGrid)

    Property Description

    Cancel Gets or sets a value indicating whether the event is canceled.

    DeletedRows Gets the deleted rows.

    Our Use Case:

    The user want to delete a row from c1datagrid.

    in this event we check some conditions and maybe ask the user if he really want to delete rows.

    If not all conditions fulfilled → Cancel = true.

    Else → c1datagrid should be fired ‘RowsDeleted’ event.

    RowsDeleted Event (C1DataGrid)

    Property Description

    DeletedRows Gets the deleted rows.

    Our Use Case:

    If fired (because conditions checked in DeletingRows event),

    delete in database and make some other things.

    justmy2cents:

    If the ‘RowsDeleted’ event only for internal purpose of sorting or filtering it should not be public.

    my workaround:

    move all stuff to DeletingRows event.

    Regards

  • Posted 10 October 2023, 2:54 am EST

    Hi Sebastian,

    > If the ‘RowsDeleted’ event only for internal purpose of sorting or filtering it should not be public.

    Thank you for your suggestion.

    RowDeleted event is fired internally in the case scenarios (sorting or filtering) discussed in the previous comments. This event is also fired after a row is deleted during runtime, therefore its accessibility cannot be restricted. Please note that C1DataGrid is a legacy control and is not under active development. We suggest the users to migrate to C1FlexGrid as this is has been replaced by C1DataGrid.

    > my workaround:

    move all stuff to DeletingRows event.

    Since RowDeleted event is being fired in the sorting and filtering scenarios, you can definitely consider handling DeletingRows event if it suits your use-case.

    Kindly let us know if you need any further help regarding this.

    Thanks & Regards,

    Aastha

Need extra support?

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

Learn More

Forum Channels