row select in table

row select in table

kellykelly Posts: 2Questions: 0Answers: 0
edited November 2012 in General
var 123;

$(function() {

123 = $("#1234").dataTable({
"sScrollY": "209px",
"bPaginate": false,
"bScrollCollapse": true,
"bFilter": false,

"bAutoWidth" :true,
"bProcessing": true,
"sAjaxSource": "Data/Table_Browse_ClusterList.txt"

});

$("#1234 tbody tr").click( function( e ) {
if ( $(this).hasclass('row_selected') ) {
$(this).removeClass('row_selected');
}
else {
123.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});

-------------
I need to fix my source code. I want to select rows in table and do something with that rows but I can't select rows.
what's wrong?
I hope your help.

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    edited November 2012
    http://datatables.net/faqs#ss_events (this applies here since you are using Ajax source - the problem is more accurate with server-side processing, but the same principle applies - use a live/delegate event).

    Allan
  • TiaxTiax Posts: 12Questions: 0Answers: 0
    Also note that you cannot name a javascript variable "123" as it cannot start with a number ;)
  • kellykelly Posts: 2Questions: 0Answers: 0
    edited November 2012
    um.. thanks comments
    and sorry I didn't express exactly my code
    actually 123 is just a symbol in there. real Id in my code isn't 1234 or 123
    I guess the problem is.....
    "sAjaxSource": "Data/Table_Browse_ClusterList.txt"

    because my code ran well before addition that code.
    I changed the method to add data in table(tbody)
This discussion has been closed.