srikanth
srikanth

Reputation: 85

How to get Filtered row data values in ng2-smart-table

I am using ng2-smart-table module to display the data in the grid format. I want to export the filterd data into the xls file.

Table with the values and first column is check box, filtered one coumn data and get the 10 rows , aftet that click on select all check box from the header its selecting all the 10 rows (checked all the 10 rows) and click on export button, only 10 row values should be in xls file. but my xls file having all the data values which are coming from the data base.

Upvotes: 1

Views: 3244

Answers (1)

Sachin Shah
Sachin Shah

Reputation: 4533

Try this way

The first way :

In this way you are just set your custom checkbox and get the event.

import { DomSanitizer } from '@angular/platform-browser';
...
constructor(private _sanitizer: DomSanitizer) { }
...
public settings = {
  columns: {
   checkbox: {
    title: 'Check Box',
    type: 'html',
    valuePrepareFunction: (value) => { return this._sanitizer.bypassSecurityTrustHtml(this.input); },
    filter: false
   },
 }
};
...
public input: string = '<input type="checkbox"></input>';

The second way :

For the documentation you will able to fetch selected row data by implement userRowSelect in your ng2-smart-table.

<ng2-smart-table [settings]="settings" [source]="source" (userRowSelect)="onUserRowSelect($event)"></ng2-smart-table>

In your .ts file just implement onUserRowSelect() and store in array.

onUserRowSelect(event): void {
    console.log("Row is ::: ",event);
}

For information read this events

Upvotes: 2

Related Questions