I am using SmartAdmin Angular 5 framework 1.9.1, which provides DataTables capabilities. I have installed DataTables 1.10.18, and Select 1.2.6.
I have the following component.html code, showing only the sa-datatables plugin usage"
<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>
The datatable that is created works fine. I get the checkboxes, and the Delete button does call function handleDelete(). My problem is not knowing how to pass, or get, the selected rows in the handleDelete() function, which I have defined in component.ts.
The DataTables Editor has a Soft Delete example, using jQuery that defines the selected rows like this:
var rows = table.rows( {selected: true} ).indexes();
I have tried modifying the sa-datatable, like so:
<sa-datatable id='table' name='table'
[options]="{
...
action: handleDelete(table.rows( {selected: true} ).indexes())
...
</sa-datatable>
but, it generates a compile error because table is undefined.
Any ideas on how to get a list of selected rows in component.ts?
Thanks,
Bob