Implementation of edit and delete with action buttons without editor plugin

Implementation of edit and delete with action buttons without editor plugin

TitaniaTitania Posts: 6Questions: 3Answers: 0
edited July 2016 in Free community support

Hello. I'm using DataTables and I need to implement edit (inline) and delete actions without editor plugin.

I only managed to render buttons. This is my table definition:

var table = $('#datatable').DataTable({
            pagingType: "full_numbers",
            dom : 'Bfrtip',
            ajax : {
                url: '....'
            },
            sAjaxDataProp: "",
            columns: [
                {data : 'id'},
                {data : 'name'},
                {
                    orderable: false,
                    className: 'text-right',
                    render: function (data, type, row) {
                        return '<a class="btn btn-danger" data-id="' + row[1] + '">' +
                            '<span class="glyphicon glyphicon-trash"> </span>' +
                            '</a>'
                        +
                            '<a class="btn btn-primary" data-id="' + row[1] + '">' +
                            '<span class="glyphicon glyphicon-pencil"> </span>' +
                            '</a>'
                    }
                }
            ],
            order: [[ 0, "asc" ]],
            select: true
        });

But I don't know how (or where) to implement functionality that buttons represent - how to reference the button and assign onClick event or whatever I'm suppose to do. What I'm trying to achieve is this:

  • when edit button is selected:

    • ALL values in the row become selectable/editable (i need to fetch selectable data from server)
    • column with edit and delete buttons rerenders with save and cancel buttons instead of edit and delete
  • when delete button is selected:

    • a confirm dialog shows

I don't know where to write this code that triggers on click and how to fetch data from the server. Can someone please give some directions?
I'm really confused and I've been trying to find something useful but most of the questions/answers are not for the beginners.

Answers

  • elimariaaaelimariaaa Posts: 30Questions: 11Answers: 0

    Hi Titania,

    Are you able to implement this on a server-side approach? I'm interested to know. I'd be grateful if you have a fiddle or something.

    Thanks! :)

    Eli

  • rentayustikrentayustik Posts: 1Questions: 0Answers: 0

    Hello Titania,
    I have the same problem with you.
    I wanna ask you if you have found the solution for the problem yet?
    That would be my pleasure if you have found it and wanna share with me.
    Thank you

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Have you tried using Editor? I suspect the effort required to implement your own would be far more greater than the license fee.

    Colin

This discussion has been closed.