fnStandingRedraw is not working
fnStandingRedraw is not working
lordoffriends
Posts: 14Questions: 2Answers: 0
This function as given in the API is not working correctly for me.It does get called and executes perfectly.But the page doesn't remain on the same page when some row on it was deleted.
This is the code :-
$(document).ready(function() {
$('#example tbody tr').live('click', function (event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
aData = oTable.fnGetData(this); // get datarow
row = $(this).closest("tr").get(0);
});
/* Add a click handler for the delete row */
$('#delete').click( function() {
$.ajax({
type: "GET",
url: "<?php echo base_url(); ?>Test/DeleteData",
data: "id="+aData[0],
success: function(msg){
var anSelected = fnGetSelected( oTable );
oTable.fnDeleteRow( anSelected[0] );
oTable.fnDeleteRow(oTable.fnGetPosition(row));
oTable.fnStandingRedraw(oTable.fnSettings());
}
});
} );
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i
This is the code :-
$(document).ready(function() {
$('#example tbody tr').live('click', function (event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
aData = oTable.fnGetData(this); // get datarow
row = $(this).closest("tr").get(0);
});
/* Add a click handler for the delete row */
$('#delete').click( function() {
$.ajax({
type: "GET",
url: "<?php echo base_url(); ?>Test/DeleteData",
data: "id="+aData[0],
success: function(msg){
var anSelected = fnGetSelected( oTable );
oTable.fnDeleteRow( anSelected[0] );
oTable.fnDeleteRow(oTable.fnGetPosition(row));
oTable.fnStandingRedraw(oTable.fnSettings());
}
});
} );
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i
This discussion has been closed.
Replies
oTable.fnDeleteRow( anSelected[0] );
oTable.fnDeleteRow(oTable.fnGetPosition(row));
oTable.fnStandingRedraw(oTable.fnSettings());
[/code]
You are redrawing the table 3 times there. http://datatables.net/api#fnDeleteRow - you need to tell delete row to not redraw the table.
Allan
$(document).ready(function() {
$('#example tbody tr').live('click', function (event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
aData = oTable.fnGetData(this); // get datarow
row = $(this).closest("tr").get(0);
});
/* Add a click handler for the delete row */
$('#delete').click( function() {
//oTable.fnDraw(false);
$.ajax({
type: "GET",
url: "<?php echo base_url(); ?>Test/DeleteData",
data: "id="+aData[0],
success: function(msg){
oTable.fnDeleteRow(oTable.fnGetPosition(row),null,false);
oTable.fnStandingRedraw(oTable.fnSettings());
}
});
} );
/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i
oTable.fnStandingRedraw(oTable.fnSettings());
oTable.fnDeleteRow(oTable.fnGetPosition(row),null,false);
Now what happens is ...the deletion works for the first time.The DOM row gets deleted and page stays on the same page.But every second deletion on a page different from first page,the page is redirected to 1st page lol...Plz brother,i am waiting for the solution.Help me on this.I have to submit the project today.