Custom button form message

Custom button form message

Description of problem:
I have a custom button "Delete All" which deletes all selected rows based on search. Before delete function, I want to display a form message warning the user about the delete all. I am unable to show the form message though I have the details.

{
                text: '<i class="fa fa-trash"></i> Delete all',
                className: 'btn btn-danger btn-editor-remove',
                
                formMessage: function ( e, dt ) {
                    return 'Do you want to delete all selected rows?';
                },
                action: function () {
                   
                        table.ajax.url("/xxxxxxxx?contentType=application/json");
                        table.page(0);
                        table.ajax.reload();
                        // set the URL back to the normal browsing call
                        table.ajax.url("/xxxxxxxxxxxxx?contentType=application/json");
                    
                }
            }

Also there is already and single row delete button on the table. I could use the simple javascript confirm dialog, but it looks quite different from form message. Please help.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 16,799Questions: 25Answers: 3,982

    I've never used this but from what I gather the formMessage option is used with Editor buttons, like this example. Are you using this with the Editor?

    Kevin

  • andreas.heckwolf@menturagroup.comandreas.heckwolf@menturagroup.com Posts: 12Questions: 4Answers: 0

    Hello Kevin,

    Yes I am using this button as part of Editor buttons. I am using CRUD buttons along with this custom button. I need a warn form message for this custom button, but even after defining it in the button, it does not pup-up. Let me know if I am missing something.

    In the example you have shown, the buttons have used 'extend' keyword. I have not used it as it is a custom button. Is it Ok to use 'extend' for custom button also? (Already there is a button extending 'remove' to delete a row)

    Thanks
    Andreas

  • colincolin Posts: 14,452Questions: 1Answers: 2,462

    I'm not sure if you're aware, but the standard Delete button does that behaviour already. If you look at this example, select a couple of rows, and then press "Delete", you'll see the warning message and then all rows are removed.

    It might be useful if you tell us what you're trying to achieve, as there may be an alternative way of doing it,

    Colin

  • andreas.heckwolf@menturagroup.comandreas.heckwolf@menturagroup.com Posts: 12Questions: 4Answers: 0

    Hello Colin,

    I am using Search box to filter out the rows and then Click "Delete All" to delete the selected rows from the search. This comes handy when we have many rows to delete based on search criteria.

    Thanks
    Andreas

  • colincolin Posts: 14,452Questions: 1Answers: 2,462
    Answer ✓

    I think this is doing what you're after - http://live.datatables.net/vehebuxu/1/edit

    There's a new button that will delete all records returned by a search - I've tweaked it so that if there isn't an active search, it does nothing, but you can customise that,

    Colin

  • andreas.heckwolf@menturagroup.comandreas.heckwolf@menturagroup.com Posts: 12Questions: 4Answers: 0

    Hello Colin,

    Thanks for posting the example. That helped.

    Thank You
    Andreas

Sign In or Register to comment.