Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ng2-smart table get selected rows using checkbox

Tags:

angular

i am using angular 2 with ng2-smarttable.

I add checkbox in table.Here is my code.

settings = {
    mode:"external",
    selectMode: 'multi',
    columns: {
       Check:{
        title: '',
        type: 'html',
        valuePrepareFunction: (value) => { return this._sanitizer.bypassSecurityTrustHtml(this.input); },
        filter: false
       },
       orderby:{
        title: "Name",
        filter: true
       }
 }

it's works.But i need get checkbox with event and get selected row.

Kindly advice me,

Thanks.

like image 312
sarankani Avatar asked Mar 08 '23 05:03

sarankani


1 Answers

Add "userRowSelect" event your HTML code as below.

 <ng2-smart-table class="table table-bordered" [settings]="settings" [source]="data" (create)="onAdd($event)"
             (delete)="onDelete($event)" (userRowSelect)="onUserRowSelect($event)">
 </ng2-smart-table>

Add your method as below and it will return all selected rows.

public onUserRowSelect(event) {
  var selectedRows = event.selected;
}
like image 56
Thinira Avatar answered Mar 21 '23 02:03

Thinira