How to delete a row on client-side only with data from server-side?
How to delete a row on client-side only with data from server-side?
Hi there, I'm new to DataTables and I really need your help, here is my current script :
[code]
var oTable;
var giRedraw = false;
$(document).ready(function() {
$("#example tbody").click(function(event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
});
$('#delete').click( function() {
var anSelected = fnGetSelected(oTable);
oTable.fnDeleteRow(anSelected[0]);
});
oTable = $('#example').dataTable({
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "data_json.php",
"sScrollY": "500px",
"bPaginate": false,
"bScrollCollapse": true,
"sPaginationType": "full_numbers"
});
});
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i
[code]
var oTable;
var giRedraw = false;
$(document).ready(function() {
$("#example tbody").click(function(event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
});
$('#delete').click( function() {
var anSelected = fnGetSelected(oTable);
oTable.fnDeleteRow(anSelected[0]);
});
oTable = $('#example').dataTable({
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "data_json.php",
"sScrollY": "500px",
"bPaginate": false,
"bScrollCollapse": true,
"sPaginationType": "full_numbers"
});
});
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i
This discussion has been closed.
Replies
You can't :-). This is intentional! You've got server-side processing enabled, so all the data is held at the server - thus if you want to remove a row, you need to remove it at the server-side - the client-side table simply reflects what is available on the server.
For example, if you could delete rows client-side, then you did a sort, the server would sort the table with your deleted row still in it - which is wrong.
So the data processing is either all client-side or all server-side.
Allan
Allan