javascript - Selectable rows for more than one Datatable a page? -
i need option choose rows on 2 different datatables independently few pages. these tables have different buttons manipulate tables according selected row. here code select row 1 table: https://datatables.net/release-datatables/examples/api/select_single_row.html cannot work more 1 table, if duplicate of code , use different ids. http://jsfiddle.net/bwcbx/ ideas?
var otable; $(document).ready(function() { /* add click handler rows - used callback */ $("#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'); } }); /* add click handler delete row */ $('#delete').click( function() { var anselected = fngetselected( otable ); if ( anselected.length !== 0 ) { otable.fndeleterow( anselected[0] ); } } ); /* init table */ otable = $('#example').datatable( ); } ); /* rows selected */ function fngetselected( otablelocal ) { return otablelocal.$('tr.row_selected'); }
in code of jsfiddle, in version 2 of click , delete functions, forgot change otable otable2, why duplicate code don't work.
Comments
Post a Comment