Using select a row for more than one Datatable a page?

Using select a row for more than one Datatable a page?

triplethreat77triplethreat77 Posts: 4Questions: 4Answers: 0
edited September 2013 in General
I am able to select a row within my datatable, but I have more than one table with different options, and the example here https://datatables.net/release-datatables/examples/api/select_single_row.html will only work with one. Each table works independently, and I can't seem to manipulate this to work for me. I also posted help on Stack Overflow, with no response so far. http://stackoverflow.com/questions/18851323/select-a-row-on-datatables-allowed-on-more-than-one-table-a-page

Replies

  • fearednerdfearednerd Posts: 44Questions: 0Answers: 0
    edited September 2013
    Sorry if I am misinterpreting anything but from what I understand is that you just want to select on 2 different tables independently. So no cross functionality is needed?

    I am not 100% sure but I feel like you can manipulate:
    [code]
    $("#example tbody tr").click( function( e ) {
    if ( $(this).hasClass('row_selected') ) {
    $(this).removeClass('row_selected');
    }
    else {
    oTable.$('tr.row_selected').removeClass('row_selected');
    $(this).addClass('row_selected');
    }
    });
    [/code]

    the #example refers to the table id, so I am assuming creating another jquery function like this one but change #example to the tables names that you have. Hopefully this helps.

    Also oTable is the variable name he set up, you obviously need to change oTable to the 2 different variable names that you have for your tables.
  • triplethreat77triplethreat77 Posts: 4Questions: 4Answers: 0
    I've actually tried setting up another function for #example2 with no luck. Also, I've tried oTable and oTable2, trying to replicated what was done in the first table with a new block of code. Maybe try this out and let me know if you can get it to work?
  • triplethreat77triplethreat77 Posts: 4Questions: 4Answers: 0
    Example http://jsfiddle.net/BWCBX/
This discussion has been closed.