CancelEditing not working

Posted by: johngiblin on 15 June 2020, 11:29 pm EST

  • Posted 15 June 2020, 11:29 pm EST

    I am trying to cancel the editing in certain circumstances,

    When I have args.oldItem.levelNum === 1 I invoke the cancel editing. It comes back the with the status of cancel editing and then opens my custom text area editor. I used the same code you used for the text area editor



    onEditingDataView(sender: any, args: any): void {
    if ((args.status === 'endEditing' && args.isNewRow) || args.status === 'cancelEditing') {
    this.dataView.invalidate();
    return;
    }

    if (args !== undefined) {
    if (args.oldItem.levelNum === 1) {
    if (args.status === 'beforeStartEditing') {
    this.dataView.cancelEditing();
    return;
    }
    }
    if (args.status === 'beforeEndEditing') {
    if (
    args.oldItem.notes !== args.newItem.notes &&
    args.newItem.notes !== '' &&
    args.oldItem != null
    ) {
    const reportKeys = {
    entityid: args.newItem.col3,
    booktaxdifferenceID: args.newItem.col6,
    };
    const notes: any = {
    ReportId: args.newItem.reportid,
    Notes: args.newItem.notes,
    ReportKeys: reportKeys,
    ReportName: 'TaxAdjBookBasisDiffBetweenBoyEoy',
    };

    this.SaveData(notes);
    }
    }
    }
    }
  • Replied 16 June 2020, 9:02 pm EST

    Hi,

    You may handle the editing event to achieve this functionality. Please refer to the following code snippet and the sample demonstrating the same:
    dv.editing.addHandler(function(e) {
    var status = e.status;

    if (status === "beforeStartEditing" && e.oldItem.country === "US") {
    e.cancel = true;
    }
    });

    https://codesandbox.io/s/dvjs-sample-2kslf?file=/src/index.js

    Regards
Need extra support?

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

Learn More

Forum Channels