1) User can navigate through the table and randomly select/deselect checkboxes.
2) Clicking on "select all" checkbox in the thead should check/uncheck all the currently visible records only.
3) The "select all" button should maintain a state(checked/unchecked) for different pages of datatables. E.g. - if the user clicks select all on page 1 and navigates to next page, the Select all checkbox should be deselected and clicking it again would check all the rows in this page only while the previously selected checkboxes stays unaffected.
I have used ng2-data-table ... my code is as follow
<th style="width: 10%">
<!--<input type="checkbox" (change)="isSelected = !isSelected" /> Actions-->
<mfRowSelectorHead></mfRowSelectorHead>
</th>
<tbody>
<tr *ngFor="let item of mf.data;let ndx = index">
<td>
<!--<input type="checkbox" [checked]="isSelected" (change)="OnClickDeleteArray(item,check.checked)" #check />-->
<mfRowSelector [entity]="item" [checkboxId]="ndx"></mfRowSelector>
<span class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Actions
</button>
<span class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<li class="dropdown-item action-dropdown" (click)="EditModel(item)">Edit</li>
<li class="dropdown-item action-dropdown" (click)="DeleteModel(item,check.checked)">Delete</li>
<li class="dropdown-item action-dropdown">View</li>
</span>
</span>
</td>
<td>{{item.AssetModelName}}</td>
<td>{{item.AssetModelManufacturerName}}</td>
<td>{{item.IsActivemodel}}</td>
</tr>
</tbody>
and code in .ts file is as follow
selectedEntities: any[];
public setSelectedEntities($event: any) {
debugger;
this.selectedEntities = $event;
}
Thank you in advance for taking time to read