Tracking changes with Customization

Posted by: bmakhlin on 30 November 2018, 4:48 pm EST

    • Post Options:
    • Link

    Posted 30 November 2018, 4:48 pm EST

    Hi,

    I am trying to implement solution based on “Tracking changes with Customization” in https://demos.wijmo.com/5/Angular2/CollectionViewIntro/CollectionViewIntro/

    I need to be able to get itemsEdited when I click save changes button.

    The problem is that Tracking changes with customization works only when you change rows. Do you have solution that allows to get itemsEdited without changing rows where itemsEdited only contains items different from original?

    Case1:

    1. Change row 1 cell value by typing in the cell.
    2. Click save changes button. Row 1 is not in itemsEdited collection. commitEdit is needed to get changes reflected in itemsEdited collection. commitEdit works if user never change rows. I can compare original row with changed row to determine if row should be removed from itemsEdited collection.

    Case 2:

    1. Change row 1 cell value
    2. Move to row 2
    3. Change row 1 cell value back to original value
    4. Click save changes button

      Row 1 is in itemsEdited collection. If I commitEdit then I loose track of original changes and can’t determine if row 1 should be removed from itemsEdited. If I save original of previous row I would be able to decide if row needs to be removed from itemsEdited but this means that I need to save originals for every rows that your solutions is trying to avoid.

    thank you

  • Posted 3 December 2018, 1:03 am EST

    Hi,

    Items are added to itemsEdited when commitEdit() is called on the collectionView instance, in grid’s case, it is called when row edit is finished to avoid unnecessary refreshes. So, you may not need to change row to get the edited items, losing focus from the grid would also commit the row edit.

    Hence, you may access the latest value of ‘itemsEdited’ collection inside the click handler for ‘save changes’ button without any additional setup.

    You may refer to the following sample: https://stackblitz.com/edit/angular-al4ukd?file=src%2Fapp%2Fapp.component.ts

    As for the second case, grid doesn’t stores the original source values, it only checks for the changes made to the current item before calling the editItem() and after calling commitEdit(), so if you would like to check if the values are reverted back to the original then keeping a clone of the original values is the only solution available for now.

    ~Sharad

Need extra support?

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

Learn More

Forum Channels