Multi-Row edit : How to append to textarea filed and preserve prior text

Multi-Row edit : How to append to textarea filed and preserve prior text

trbtrb Posts: 2Questions: 1Answers: 0

Hi -
I am using a textarea filed to add comments to the records. I have a multi-row edit where I want to append the same comment to records which may already have prior comments. When I add comments using multi-row editing it overwrites any prior comments and only retains the last comment in all the edited records. I need to append the added text and to the end of any prior comment. Any thoughts on how to accomplish this?

Thanks.

Answers

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    Yes, what you need to do is use the multi-row editing API to spin over each row individually and append the new comment to the existing comment. As you note, just using .val() will set the value to the same for each, so you need to loop over the whole lot and modify each one individually.

    let ids = editor.ids();
    
    for (let i=0 ; i<ids.length ; i++) {
      let current = editor.field('myField').multiGet( ids[i] );
    
      editor.field('myField').multiSet( ids[i], curent + '\n\n' + newComment );
    }
    

    I think should do it.

    Allan

  • trbtrb Posts: 2Questions: 1Answers: 0

    Thanks Allan...

Sign In or Register to comment.