I'm using jquery responsive datatable with my angular 6 application. I want to put two button at the last td in each row. But none of the events are working on the collapsed tds.
After setting below property on the datatable, events are working but after each event, buttons are repeated. At first I have 2 buttons, after clicking on the button and completing the operation, i get 4 buttons, and buttons keeps on increasing.
Datatable configuration:
const table: any = $('#contract-table');
table.DataTable().destroy();
this.dataTable = table.DataTable({
responsive: {
details: {
renderer: Responsive.renderer.listHiddenNodes()
}
}
});
Angular code:
<table class="table table-hover dt-responsive nowrap" id="contract-table" cellspacing="0">
<thead class="thead-dark">
<tr>
<th>Contract Number</th>
<th>Contract Title</th>
<th>Contract Type</th>
<th>DUNS</th>
<th>Cage Code</th>
<th>DoDAAC</th>
<th>DCMA Administered</th>
<th>Category</th>
<th>Customer/Agency</th>
<th>Customer/Agency Other</th>
<th>Contract Clauses</th>
<th>PWS/SOW Authroization Data</th>
<th>Contract Dollar Value</th>
<th>Contract Classification</th>
<th>Indefinite Delivery Contract</th>
<th>Indefinite Delivery Type</th>
<th>Contract Description</th>
<th></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let contract of contracts" (click)="selectedContract = selectedContract && selectedContract.id === contract.id ? null : contract" [ngClass]="{'selected-contract': selectedContract && selectedContract.id === contract.id}">
<td>{{contract?.contractNumber}}</td>
<td>{{contract?.title}}</td>
<td>{{contract?.contractType}}</td>
<td>{{contract?.duns}}</td>
<td>{{contract?.cageCode}}</td>
<td>{{contract?.doDAAC}}</td>
<td>{{contract?.dcmaAdministered ? 'Yes' : 'No'}}</td>
<td>{{contract?.category}}</td>
<td>{{contract?.customerAgency}}</td>
<td>{{contract?.customerAgencyOther}}</td>
<td>{{contract?.contractClauses}}</td>
<td>{{contract?.authorizationData}}</td>
<td>{{contract?.contractDollarValue}}</td>
<td>{{contract?.contractClassification}}</td>
<td>{{contract?.indefiniteDeliveryContract ? 'Yes' : 'No'}}</td>
<td>{{contract?.indefiniteDeliveryType}}</td>
<td>{{contract?.contractDescription}}</td>
<td>
<div class="row pull-right">
<div class="col pr-0">
<button mat-button class="btn btn-custom btn-bordred btn-block" (click)="onCreateSubContract('edit', contract)">Edit</button>
</div>
<div class="col">
<button mat-button class="btn btn-custom btn-bordred btn-block btn-create-sub-contract" (click)="onCreateSubContract('sub', contract)">Create Subcontract</button>
</div>
</div>
</td>
</tr>
</tbody>
</table>
angular click events should work fine.