Joofe Kopp Joofe Kopp - 2 months ago 8
Javascript Question

jQuery Datatable - How to delete a row using cell value

I want to search a cell in my JQuery datatable which has the content of var x and delete the row which contains the cell.

I tried this:

function deletedatarow(){
var x = "tzr";
$( "tr:contains('" + x + "')").fnDeleteRow();
};


but it doesnt work.

Can anyone tell me why and help me to find a solution?

Answer

If you're referring to the jQuery DataTables plugin, then you're doing it wrong, your code should look something like this:

// Set oDatatables variable somewhere above this line..    
function deletedatarow(){
  var x = "tzr";
  $( "tr:contains('" + x + "')").each(function() {
    oDatatables.fnDeleteRow(this);
  });
};
Comments