jquery-tabledit icon indicating copy to clipboard operation
jquery-tabledit copied to clipboard

Applying second time

Open ovidijusr opened this issue 8 years ago • 3 comments

When i reapply it on a table, cells that has selection multiplies

applying once http://i.imgur.com/rMdZuCC.png applying multiple times http://i.imgur.com/K1gy2lQ.png

How can I destroy it first?

Thanks

ovidijusr avatar Apr 13 '17 11:04 ovidijusr

Hi, I can publish a patch if you're still interested. I made some changes to allow this.

guillaumech avatar Jun 03 '17 08:06 guillaumech

Cool, thank you :)

ovidijusr avatar Jun 03 '17 19:06 ovidijusr

Hello I know it's late but I have a workaround for this: For DT 1.13+, use rowCallback callback to remove previous jq tableedit changes:

$(document).ready(function () {
    //...
    var table = $('#example').DataTable({
        // ...
        "rowCallback": function (row, data) {
            // my table contains three columns
            var $html = $('<div id="wrapper"><table><tr id="row"><td></td><td></td><td></td></tr></table></div>');
            var isTableEdit = false;
            for (var i = 0; i < 3; i++) {
                var $span = $('td:eq(' + i + ') span.tabledit-span', row);
                if ($span.length == 0)
                    break;
                else {
                    isTableEdit = true;
                    $html.find('td:eq(' + i + ')').text($span.text());
                }
            }
            if (isTableEdit)
                $(row).html($html.find("#row").html());
        }
        // ...
    });

    // on datatables draw event, apply your jq table edit, this approach supports both search and sort scenarios.
    table.on('draw.dt', function () {
        // do your table edit thing
        $('#fieldsTable').Tabledit({...});
    });

});

Hope this helps someone.

mtorak avatar Mar 09 '23 12:03 mtorak