How to add "edit" and "delete" buttons for each row while using the Editor plugin

How to add "edit" and "delete" buttons for each row while using the Editor plugin

lavapotatolavapotato Posts: 10Questions: 2Answers: 0

I see this example: https://editor.datatables.net/examples/simple/inTableControls.html

BUT it doesn't seem to pertain to using the Editor plugin. As the table is controlled via the Editor plugin (how the instances are built) so not sure how to get around this.

Basically want...

  1. the table to look like the example link above in terms of each row having its own edit and delete link
  2. ability to make the links be actual buttons, so to be able to stylize them to my own liking (ie. using bootstrap which is setup)

Any help appreciated

This question has an accepted answers - jump to answer

Answers

  • CensorNetCensorNet Posts: 5Questions: 2Answers: 0
    edited April 2015

    Hello,
    you can use the following code to get the new, edit and delete buttons on your table.
    oTable = $('#example').DataTable( {
    aButtons: [
    { sExtends: 'editor_create', editor: editor },
    { sExtends: 'editor_edit', editor: editor },
    { sExtends: 'editor_remove', editor: editor }, ]
    }
    } );
    see example : https://editor.datatables.net/examples/simple/simple.html

    Also there is an inline editor that you can activate
    https://editor.datatables.net/examples/inline-editing/simple.html

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    BUT it doesn't seem to pertain to using the Editor plugin

    It does in that it uses the Editor API. For example:

        $('#example').on('click', 'a.editor_edit', function (e) {
            e.preventDefault();
     
            editor.edit( $(this).closest('tr'), {
                title: 'Edit record',
                buttons: 'Update'
            } );
        } );
    

    from the example you linked to calls the edit() method to trigger the editing of a row.

    In the example I've used a tags, but you could use anything you like, including buttons.

    Allan

  • lavapotatolavapotato Posts: 10Questions: 2Answers: 0

    Thanks for the help... I think I've got it working now!

This discussion has been closed.