I am trying to store the value of the additionalPayerAmount before I remove the row.

I am trying to store the value of the additionalPayerAmount before I remove the row.

guccioguccio Posts: 2Questions: 1Answers: 0

I can use initEdit and it works

editor.on( 'initEdit', (e, id, values) => {

        var oldAmount = editor
                    .field( 'additionalPayerAmount' )
                    .get();

        $(currentEditAmountPrior).val(oldAmount);   

    } );    

When I use initRemove the field is blank

editor.on( 'initRemove', (e, id, values) => {

        var oldAmount = editor
                    .field( 'additionalPayerAmount' )
                    .get();

        $(currentEditAmountPrior).val(oldAmount);   

    } );    

Answers

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    edited December 2023

    The initRemove has four parameters that are passed: ( e, node, data, items ). The data parameter is an array of row(s) to be deleted. See if this gets the data of the first row:

    editor.on( 'initRemove', (e, id, values) => {
                
                var oldAmount = data[ 0 ].additionalPayerAmount;
    
                $(currentEditAmountPrior).val(oldAmount);   
    
            } );    
    

    I think the field().get() in the initRemove event doesn't work because there are no editor fields used when removing.

    Kevin

  • guccioguccio Posts: 2Questions: 1Answers: 0

    Kevin ... worked perfectly.

    editor.on( 'initRemove', (e, id, data,values) => {

            var oldAmount = data[ 0 ].additionalPayerAmount;
    
            $(currentEditAmountPrior).val(oldAmount);  
    
        } );   
    

    Just needed to add "data" to the example you wrote.

    Thank you so much for taking the time to help.

Sign In or Register to comment.