Reputation: 755
Hi am using angular 2 data-table in my project.
my tbody:
<tbody>
<tr *ngFor="let item of main.data; let ndx = index">
<td>
<mfRowSelector [checkboxId]="ndx"
[entity]="item" (change)="toggleItem(item)" (selectEntity)="main.addRemoveSelectedEntity($event)"
>
</mfRowSelector>
</td>
<td class="no-wrap">{{item.date | date}}</td>
<td class="no-wrap">{{item.currency}}</td>
<td class="no-wrap">{{item.amount | number:'.2-2'}}</td>
<td>
<input type="text" [(ngModel)]="item.amountEntered">
</td>
</tr>
</tbody>
When I select rows, selectEntity will pass the selected rows as an array. So if i select multiple i'll get an array of multiple objects. As above i have an input field, on checkbox select the value in amount td will copied over to input field. Until here is working. The problem is how I can reset this value on un-select the checkbox? Any idea guys? Thanks in advance.
My Function:
selectedRows(selectedRows: any) {
selectedRows.map(obj => {
obj.amountEntered = obj.amount;
if (obj instanceof selectedRows) {
console.log('UNDALL', obj);
}else {
console.log('ILLALLO');
}
})
this.inv_selected = selectedRows.length;
console.log("selectedRow",selectedRows, selectedRows.length);
}
Upvotes: 0
Views: 436