Editor Copy row, ckeditor

Editor Copy row, ckeditor

TronikTronik Posts: 122Questions: 28Answers: 1

I've created a button for duplicating row, everything works except the ckeditor type field.
Any thought why that is?

Also, how can I manipulate the data before, and fire functions after, a row is copied?
Using the regular pre/postSubmit functions?
If thats the case, I somehow need to know that it was a 'copy' and not a 'create' or 'edit' action

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    This example here should help with the data manipulation - if the value of 'Office' is changed during the duplication, it updates the original with the new value too. You can use that as a template for the other changes.

    I'm not why the ckeditor type doesn't duplicate. Could you update my test case above to reflect that, please, or link to your page so we can see the issue,

    Colin

  • TronikTronik Posts: 122Questions: 28Answers: 1

    Thanks, your solution seems to work, altough I had to set dupId = undefined on all create / edit actions except the copy action. For example if users clicks copy row button but cancels or closes that modal, the dupId will still be set.

    Regarding CKEditor, not sure why but I got errors from CKEditor when copying row,
    Probably trying to attach multiple times.
    I fixed it by, on duplicate action, delete possible ckeditor instances and then copy the value from the row being copied into the new row

     action: function ( e, dt, node, config ) {
                       
    var web_description = table.rows( { selected: true } ).data([0].products.web_description
                        
        for(name in CKEDITOR.instances)
        { 
            CKEDITOR.instances[name].destroy(true);
        }
    
    dupId = table.rows( { selected: true } ).data()[0]
    
     editor
          .edit( table.rows( {selected: true} ).indexes(), {
             title: '"Copy row',
             buttons: 'Create'
             } )
            .mode( 'create' )
                            
        editor.field('products.web_description').val(web_description)
                            
    }
    

    I should say Im using "onPageDisplay" editor, might be a possible reason

Sign In or Register to comment.