editor_remove fnComplete

editor_remove fnComplete

Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2
edited January 2015 in Editor

I am trying to reload the page after a row/rows have been deleted. However, the reload action takes place before the delete function has started, it occurs when the prompt 'are you sure you wish to.....' is present. How do I make the reload occur after the action has completed?

   $('#xx').dataTable( {
        "dom": 'Tfrltlpi',
        "bSortClasses": false,
        "processing": true,
        "serverSide": true,        
        "ajax": {
            "url": "/uploads/",
            "type": "POST",
            "data": function ( d ) {
                d.user_id = "x";
                d.checkcode = "x";
            }
        },
        "lengthMenu": [ [1000, 5000, 10000, 40000], [1000, 5000, 10000, 40000] ],              
        "language": {
           "search": "_INPUT_",
           "searchPlaceholder": "Search....",
           "sLengthMenu": "_MENU_ per page"
        },
        "order": [[ 2, "desc" ]],
        "columns": [
            { 
                "data": "null", defaultContent: '', orderable: false, "bSearchable": false
            },
            {
                "data": "listphone"
            },
            {
                "data": "create_date"
            },
            {
                "data": "checkcode"
            },
            {
                "data": "xx"
            }
        ],
        "columnDefs": [ {
            "targets": 2,
            "createdCell": function (td) {
                $(td).addClass('grey')
            }
        }],
        "tableTools": {
            "sRowSelect": "os",
            "sSwfPath" : "/uploads/",
            "aButtons": [
                    { 
                    "sExtends": "select_all",       
                    "sButtonClass": "select-all",                 
                    },
                    { 
                    "sExtends": "select_none",       
                    "sButtonClass": "select-none",                 
                    },   
                    {
                    sExtends: "collection",
                    sButtonText: "Copy",
                    sButtonClass: "copy-collection DTTT_disabled",
                    "aButtons": [
                    {
                    "sExtends": "copy",
                    "sButtonText": "Copy - 'Number' column only",
                    "mColumns": [1]
                    },
                    {
                    "sExtends": "copy",
                    "sButtonText": "Copy - 'All' columns",
                    "mColumns": [1, 2, 3, 4]
                    },                    
                    ]
                    },                                                             
                    {
                    sExtends: "collection",
                    sButtonText: "Save",
                    sButtonClass: "save-collection DTTT_disabled",
                    "aButtons": [                  
                    {
                    "sExtends": "csv",
                    "sButtonText": "CSV - Save 'Number' column only",
                    "mColumns": [1],
                    "sFieldBoundary": ''
                    },
                    {
                    "sExtends": "csv",
                    "sButtonText": "CSV - Save 'All' columns",
                    "mColumns": [1, 2, 3, 4]
                    },                    
                    {
                    "sExtends": "xls",
                    "sButtonText": "Excel - Save 'Number' column only",
                    "mColumns": [1]
                    },
                    {
                    "sExtends": "xls",
                    "sButtonText": "Excel - Save 'All' columns",
                    "mColumns": [1, 2, 3, 4]
                    },
                    {
                    "sExtends": "pdf",
                    "sButtonText": "PDF - Save 'Number' column only",
                    "mColumns": [1]
                    },
                    {
                    "sExtends": "pdf",
                    "sButtonText": "PDF - Save 'All' columns",
                    "mColumns": [1, 2, 3, 4]
                    },                    
                    ]
                    },
                    {
                    "sExtends": "download",
                    "sButtonText": "Save All",
                    "sUrl": "/uploads/"
                    },                 
                    { 
                    "sExtends": "editor_remove",       
                    "sButtonClass": "delete",                 
                    "editor": editor,
                    "fnComplete": function ( nButton, oConfig, oFlash ) {
                    window.location.href = window.location.href + "?delete=true";
                    }
                    },
                    {
                    "sExtends": "remove",
                    "sButtonText": "Delete All",
                    "sUrl": "/uploads"
                    }                
            ]
        }
    });
});

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    The fnComplete TableTools option doesn't have any concept of the Editor actions - it is entirely internal to TableTools, and is executed when the button click finishes. Since your Editor delete is asynchronous you get the result you see.

    Rather than using fnComplete, I would suggest you use the Editor postRemove event.

    Regards,
    Allan

  • Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

    Hi Allan,

    Thanks for the information. I am unsure exactly where to position the postRemove event. Do I use it like this>
    ?

    editor.on( 'postRemove', function ( e, json, data ) {
        $(".refresh-after-ajax").load(window.location + "?delete=true" + " .refresh-after-ajax");
    });
    

    And if so where abouts would I position that code in mine? Thanks

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    That looks good! You could put that code in immediately after your Editor initialisation.

    Allan

  • Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

    Great, thanks for your help.

This discussion has been closed.