How to display previous page record when delete last page record and redraw table
How to display previous page record when delete last page record and redraw table
mpkumar
Posts: 2Questions: 1Answers: 0
Hi,
I am using server-side processing to load datatable. Also using custom delete to delete the records. When i was in last page having single record and try to delete the records. Once delete the record, i used table draw, but it displaying last page only. Needs to show previous page. Below is my code to delete the record,
$('#user_list_table tbody').on('click', '.user-remove', function(e) {
user_guid = $(this).attr('id');
if(confirm('Are you sure want to delete this User?')) {
$('#loader').show();
elgg.action('administration/users/delete', {
data: {
guid: user_guid
},
success: function(json) {
table.draw('full-hold'); // redrawing datatable
$('#loader').hide();
return false;
}
});
}
});
Thanks
This discussion has been closed.
Answers
That part is extremely confusing to me... do you mean when you redraw the table, it resets the paging? If so, The
draw
takes a parameter to fix that.. read the docs for it ;-)Hi,
I used table.draw('full-hold'); to redraw the table with current page. ie) if i am in page '5' and once the record deleted in that page, i used to show the same page after delete.
The problem is when i delete the records in last page, it showing last page with empty record even-though records available in previous pages. So needs to show the previous records if current page is empty.
I used custom delete button and perform delete action on ajax and draw the table in ajax success block.
Thanks.
Youre Gonna have to recreate it on live.datatables.net, sorry.
See this thead here for possible workarounds.