How to use datatables (jQuery datagrid plugin) to implement validation and deletion function?

I use the jQuery plugin Datatables to manage my strings. Actually it has a tabletools plugin that allows me to check the function, however I can check all the elements / check a few, but how to add a delete button and return the selected row ?

I already have a sql query to delete and a pop-up function with a delete warning.

thanks

Select all in datatable format

A document on how to get a string, but I still don't understand how to do it, thanks

$(document).ready( function () { $('#viewSub').dataTable( { "sDom": 'T<"clear">lfrtip', "oTableTools": { "sSwfPath": "../plugin/DataTables-1.9.0/extras/TableTools/media/swf/copy_cvs_xls_pdf.swf", "sRowSelect": "multi", "aButtons": [ "select_all", "select_none", "copy", "print", "delete", <===********can not add here, seems only allow pre-defined button. { "sExtends": "collection", "sButtonText": "Save", "aButtons": [ "csv", "xls", "pdf" ] } ] } } ); } ); 
+6
source share
1 answer

You can add a function to catch the selected line:

 $(document).ready( function () { $('#example').dataTable( { "sDom": 'T<"clear">lfrtip', "oTableTools": { "fnRowSelected": function ( node ) { alert( 'The row with ID '+node.id'+ was selected' ); } } } ); } ); 

In this function, you can, for example, add the specified value of the hidden field in node.id , a simple <button>Delete</button> and onClick to this button to delete the row with the selected identifier.

Check also the answers to this question .

+2
source

Source: https://habr.com/ru/post/912063/


All Articles