I want to stop auto retrieving Data after added/deleted a row
I want to stop auto retrieving Data after added/deleted a row
scott
Posts: 1Questions: 0Answers: 0
hi all!
while i deleted a row , it auto retrieve all data again , so ,how to stop it ? i want to update the whole table when i pushed a button ,not immediately .
[code]oTable = $('#example').dataTable({
"bJQueryUI" : true,
"bServerSide" : true,
"bProcessing" : true,
"sAjaxSource" : "listUserInfo.action",
"fnServerData" : retrieveData,
"sPaginationType" : "full_numbers",
"aoColumns" : [ {
"mDataProp" : "userid",
"sTitle" : "userid"
}, {
"mDataProp" : "username",
"sTitle" : "username"
}, {
"mDataProp" : "userage",
"sTitle" : "userage"
}, {
"mDataProp" : "usersex",
"sTitle" : "usersex"
} ]
});
function retrieveData(sSource, aoData, fnCallback) {
$.ajax({
"type" : "POST",
"url" : sSource,
"dataType" : "json",
"data" : aoData,
"success" : function(resp) {
fnCallback($.parseJSON(resp.returnMessage));
}
});
}
$("#example tbody").click(function(e) {
if ($(event.target.parentNode).hasClass('row_selected')) {
$(event.target.parentNode).removeClass('row_selected');
} else {
oTable.$('tr.row_selected').removeClass('row_selected');
$(event.target.parentNode).addClass('row_selected');
}
});
$("#delete").click(function() {
var anSelected = fnGetSelected(oTable);
if (anSelected.length != 0) {
oTable.fnDeleteRow(anSelected[0],null,false);
} else {
alert("pls select a row!");
}
});
var giCount = 1;
function addRow() {
oTable.fnAddData({
"userid" : giCount + ".1",
"username" : giCount + ".2",
"userage" : giCount + ".3",
"usersex" : giCount + ".4"
},false);
giCount++;
}
[/code]
[quote]
JSON:
{"bq":null,"returnMessage":"{\"iTotalDisplayRecords\":19,\"iTotalRecords\":19,\"aaData\":[{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":1},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":2},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":3},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":4},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":5},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":6},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":7},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":8},{\"username\":\"23\",\"userage\":\"423\",\"usersex\":\"1\",\"userid\":9},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":10}],\"sEcho\":\"sEcho\"}","user":null}
[/quote]
also fnDeleteRow and fnAddData did not work.
Any help would be appreciated!
while i deleted a row , it auto retrieve all data again , so ,how to stop it ? i want to update the whole table when i pushed a button ,not immediately .
[code]oTable = $('#example').dataTable({
"bJQueryUI" : true,
"bServerSide" : true,
"bProcessing" : true,
"sAjaxSource" : "listUserInfo.action",
"fnServerData" : retrieveData,
"sPaginationType" : "full_numbers",
"aoColumns" : [ {
"mDataProp" : "userid",
"sTitle" : "userid"
}, {
"mDataProp" : "username",
"sTitle" : "username"
}, {
"mDataProp" : "userage",
"sTitle" : "userage"
}, {
"mDataProp" : "usersex",
"sTitle" : "usersex"
} ]
});
function retrieveData(sSource, aoData, fnCallback) {
$.ajax({
"type" : "POST",
"url" : sSource,
"dataType" : "json",
"data" : aoData,
"success" : function(resp) {
fnCallback($.parseJSON(resp.returnMessage));
}
});
}
$("#example tbody").click(function(e) {
if ($(event.target.parentNode).hasClass('row_selected')) {
$(event.target.parentNode).removeClass('row_selected');
} else {
oTable.$('tr.row_selected').removeClass('row_selected');
$(event.target.parentNode).addClass('row_selected');
}
});
$("#delete").click(function() {
var anSelected = fnGetSelected(oTable);
if (anSelected.length != 0) {
oTable.fnDeleteRow(anSelected[0],null,false);
} else {
alert("pls select a row!");
}
});
var giCount = 1;
function addRow() {
oTable.fnAddData({
"userid" : giCount + ".1",
"username" : giCount + ".2",
"userage" : giCount + ".3",
"usersex" : giCount + ".4"
},false);
giCount++;
}
[/code]
[quote]
JSON:
{"bq":null,"returnMessage":"{\"iTotalDisplayRecords\":19,\"iTotalRecords\":19,\"aaData\":[{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":1},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":2},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":3},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":4},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":5},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":6},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":7},{\"username\":\"22\",\"userage\":\"22\",\"usersex\":\"1\",\"userid\":8},{\"username\":\"23\",\"userage\":\"423\",\"usersex\":\"1\",\"userid\":9},{\"username\":\"11\",\"userage\":\"11\",\"usersex\":\"2\",\"userid\":10}],\"sEcho\":\"sEcho\"}","user":null}
[/quote]
also fnDeleteRow and fnAddData did not work.
Any help would be appreciated!
This discussion has been closed.