Clone record in Editor

Clone record in Editor

360webmarketin360webmarketin Posts: 3Questions: 0Answers: 0
edited April 2013 in Editor
Hello Alan

I'm using Editor, and i want to add a button that makes duplicate a database entry and insert it after te original entry.

Is this possible ?

Anouar

Replies

  • allanallan Posts: 60,962Questions: 1Answers: 9,939 Site admin
    Absolutely! The way to do this is to create a new record, based on the information of the selected record and using the Editor API. So you might do something like:

    [code]
    var data = this.fnGetSelectedData();
    if ( data !== 1 ) {
    return;
    }

    editor.create( null, null, false );
    editor.set( 'name', data[0].name );
    editor.set( 'access', data[0].access );
    // ...
    editor.submit();
    [/code]

    I've only got it working on a single row there, but I'm sure you can see how you could actually extend it to work on multiple rows if needed as well.

    Regards,
    Allan
This discussion has been closed.