new added rows cannot be selected?

new added rows cannot be selected?

menkey18menkey18 Posts: 12Questions: 0Answers: 0
edited July 2011 in General
hi,

I am new to this, but I tried to combine a few examples provided to created a table that gets dynamic rows, and be able to select the rows newly generated. At the moment it is still unsuccessful, so it will be great to get some help. Cheers.

These are the codes I have been using, only the first row "allen" can be deleted:
[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">





DataTables example

@import "DataTables-1.8.1/media/css/demo_page.css";
@import "DataTables-1.8.1/media/css/demo_table.css";





/* Global var for counter */
var giCount = 1;

$(document).ready(function() {
/* Add a click handler to the rows - this could be used as a callback */
$('#example tr').click( function() {
if ( $(this).hasClass('row_selected') )
$(this).removeClass('row_selected');
else
$(this).addClass('row_selected');
} );

/* Init the table */
var oTable = $('#example').dataTable( );
} );

/*
* I don't actually use this here, but it is provided as it might be useful and demonstrates
* getting the TR nodes from DataTables
*/
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();

for ( var i=0 ; i

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You would need to use live events rather than static ones (see this FAQ: http://datatables.net/faqs#events ).

    I would perhaps suggest that you might want to look at using TableTools for row selection since it has row selection options built-in and an API to help access information about those rows. For example: http://datatables.net/release-datatables/extras/TableTools/select_multi.html

    Allan
This discussion has been closed.