Deleting rows permanently from database

Deleting rows permanently from database

sylviarssylviars Posts: 2Questions: 0Answers: 0
edited June 2011 in General
Helo, i am using datatables, i have selected multiple rows and deleting multiple rows on click of delete button., but they get deleted at runtime and not from database. i want to delete rows from database as well.
[code]

var oTable;
var giRedraw = false;

$(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');
} );


/* Add a click handler for the delete row */
$('#delete').click( function() {
var anSelected = fnGetSelected( oTable );
alert(anSelected.id);
for (var n=0; n

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    edited June 2011
    You need to send an Ajax request to the server which will then do "DELETE FROM whatever WHERE something=somethingelse" on your database. DataTables doesn't have any knowledge of your data source (the schema, if it is even SQL or whatever) so it can't action that itself - you'll need to build up the Ajax request and fire it off as you would do normally.

    Allan
  • anjibmananjibman Posts: 115Questions: 10Answers: 0
    Assuming we can get the unique id of the each row matching the row in the table.

    [code]
    $('#delete').click( function() {
    var oTable = $('#myTable').dataTable();
    var aTrs = oTable.fnGetNodes();
    for ( var i=0 ; i
This discussion has been closed.