I am currently working with the component.html code below, which is using a DataTables plugin. The issue I am facing is that when I select rows and click the Delete button, the handleDelete()
function is called. However, I am unsure of how to pass the selected rows to the handleDelete()
function. I have come across a example from DataTables Editor that uses jQuery to achieve this, but I would like to stick to using only Angular code. I have attempted to name the table and use an [(ngModel)] parameter, but this resulted in compile errors.
jQuery parameter
var rows = table.rows( {selected: true} ).indexes();
component.html
<sa-datatable
[options]="{
data: sysMsgs,
columns: [
{data: 'checked'},
{data: 'rowid'},
{data: 'senderID'},
{data: 'message'},
{data: 'dateCreated'}
],
buttons: [ 'copy', 'csv', 'pdf', 'print',
{
extend: 'selected',
text: 'Delete',
action: handleDelete()
}
],
columnDefs: [
{
targets: 0,
orderable: false,
className: 'select-checkbox'
},
{
targets: [2],
visible: true
}
],
select: {
style: 'os',
selector: 'td:first-child'
},
order: [[ 1, 'asc' ]],
searching: true,
search: {
smart: false
}
}"
tableClass="table table-striped table-bordered table-hover">
<thead>
<tr>
<th data-hide="mobile-p">Select</th>
<th data-hide="mobile-p">ID</th>
<th data-hide="mobile-p">Sender</th>
<th data-hide="mobile-p">Message</th>
<th data-hide="mobile-p">Date Sent</th>
</tr>
</thead>
</sa-datatable>