Confirm delete on tabletools?

Confirm delete on tabletools?

StpdudeStpdude Posts: 30Questions: 0Answers: 0
edited February 2013 in TableTools
Heya, so ive got a ajax delete command tied into an ajax button and am trying to implement a confirm window on it, so the user clicks delete and it pops up asking them to confirm they want to delete it:
[code]
{
"sExtends": "ajax",
"bSelectedOnly": "true",
"sButtonText": "Delete Selected",
"mColumns": [0],
"bHeader": false,
"sAjaxUrl": "dataTable/delete/cmsGroup",

"fnAjaxComplete": function ( XMLHttpRequest, textStatus ) {
$('tr.DTTT_selected').remove();
}//delete button
},
[/code]
now i hand wrote it out using a function call, but its MUCH more complex then the simple button is:
[code]
{
"sExtends": "text",
"sButtonText": "Delete",
"fnClick": function(nButton, oConfig, nRow){
if (confirm('Are you sure want to delete this record?')) {
var list = $('tr.DTTT_selected > td.sorting_1 > a').map(function () {
return this.text;
}).get().join(",");
$.ajax({
type: "POST",
url: "dataTable/delete/cmsGroup",
data: 'tableData='+ list,
success: function(result) {
alert("Entry Deleted");
$('tr.DTTT_selected').remove();
}});
}}},[/code]

Anyone know how to tack that confirm onto the regular tabletools method?

Replies

  • StpdudeStpdude Posts: 30Questions: 0Answers: 0
    Bumping this as i still need to figure this one out :)
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    Not sure what you mean by a regular tabletools method?

    Your method of using fnClick to perform the actions you want looks correct to me.

    Allan
  • StpdudeStpdude Posts: 30Questions: 0Answers: 0
    Allan-

    'table tools method' i mean i was styling it off the TableTools buttons examples, using the listed ajax options.

    What id like to do is use the styling in the first code block i posted. Using more simple commands, its cleaner and simpler to pass the mColumns [0] to pass the ID of my data over to the server for delete. However i want the user to be prompted to confirm deleting X number of rows. In my custom written block (2nd code block) ive written it all and wrapped it in a if confirm, i just havent been able to figure out how to implement that in my first code section.
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    The `ajax` button in TableTools generally expects you do override fnClick with your on options. If you want to tidy your code up to make it a bit more simple, you might consider writing a TabelTools button plug-in that defines the options you want. That's the approach Editor takes with it's delete row option.

    Allan
This discussion has been closed.