Column index of item displaying under responsive rendering

Column index of item displaying under responsive rendering

DB10DB10 Posts: 7Questions: 1Answers: 0

Hi,

Apologies for the poor subject line, I'm hoping to make a better job of explaining my issue in the text below.

My example can be found at the following link https://jsbin.com/junemum/edit?html,js,console,output

The example is somewhat contrived but my issue is that I'm using DataTables with the responsive plugin and have a number of columns using a custom renderer. Some of the columns being custom rendered could, for example, contain a hyperlink. For columns that aren't being custom rendered, there are cases where clicking on one or more cells should launch various actions and so, ultimately, what I'm trying to do, or need to do, rather, is determine the column index of the cell that was clicked. This works fine except for when I'm in "responsive mode" where, when this is expanded to show the details, and I click on one of the items in the list, I get the "cannot read property 'column' of undefined".

Is there a way to determine the corresponding column index of the list item that's been clicked on when clicking such an item in the responsive view?

Thanks in advance for any and all help

Replies

  • allanallan Posts: 61,771Questions: 1Answers: 10,112 Site admin

    Hi,

    Thanks for the example - here is an updated one with how it can be done: https://jsbin.com/tuconehule/edit?html,js,output .

    The key thing to realise is that you can pass the li element from the responsive row (or a child of it) into the cell() selector and it will resolve the cell from it (there are data attributes added to the li to allow that to happen.

    Allan

  • DB10DB10 Posts: 7Questions: 1Answers: 0

    Holy....Arsene Wenger! That's sensational. Thanks so much for that, you're unbelievably kind and, needless to say, absolutely brilliant!

This discussion has been closed.