How to get the closest TR when clicking on a FIXED COLUMN

How to get the closest TR when clicking on a FIXED COLUMN

daveeeeedaveeeee Posts: 8Questions: 3Answers: 0

I am using datatables and I have a FIXED COLUMN for edit delete function,

Currently, I want is when I click on edit the whole row will become editable with input.

Similar like this
http://plnkr.co/edit/B9fJQwgdLXEqBhrIJI76?p=preview

My issue is since I use FIX COLUMN, I cannot use now the function

 $("#example").on('mousedown.edit', "i.fa.fa-pencil-square", function(e) {

    $(this).removeClass().addClass("fa fa-envelope-o");
    var $row = $(this).closest("tr").off("mousedown");
    var $tds = $row.find("td").not(':first').not(':last');

    $.each($tds, function(i, el) {
      var txt = $(this).text();
      $(this).html("").append("<input type='text' value=\""+txt+"\">");
    });

  });

Any help will be appreciated.

Answers

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

    Hi @daveeeee ,

    There's a lot there, different classes for example. We're happy to take a look. As per the forum rules, if you could link to a running test case showing the issue we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • allanallan Posts: 63,480Questions: 1Answers: 10,467 Site admin

    fixedColumns().rowIndex() is probably what you want.

    Allan

  • daveeeeedaveeeee Posts: 8Questions: 3Answers: 0

    Thans Allan!

This discussion has been closed.