mardi 17 décembre 2019

How to uncheck particular row checkbox using ngx datatable

i have my ngx datatable

 <ngx-datatable class="bootstrap" [rows]="stockInDataList" [headerHeight]="50"                             
                                [footerHeight]="50" [rowHeight]="'auto'" [scrollbarH]="true" [columnMode]="'force'"
                                [limit]="limit" [sorts]="[{prop: 'Sno', dir: 'asc'}]" [trackByProp]="'productId'">
                                <ngx-datatable-column *ngFor="let column of DisplayColumns" [name]="column.name">
                                    <ng-template let-column="column" ngx-datatable-header-template>
                                        <span></span>
                                    </ng-template>
                                    <ng-template ngx-datatable-cell-template let-rowIndex="rowIndex" let-value="value"
                                        let-row="row">
                                        <span *ngIf="column.name !== 'Actions'"></span>
                                        <span *ngIf="column.name === 'Actions'">
                                            <button class="btn btn-primary mr-1 btn-fab" placement="top" [disabled] ="isStockEdit" ngbTooltip="Edit"
                                                (click)="Edit(row)">
                                                <i class="ft-edit"></i>
                                            </button>
                                            <input type="checkbox" class="btn btn-warning mr-1 btn-fab" [checked]="accepted" (change)="changed(row, $event.target.checked)" />                                                                           
                                        </span>
                           </ng-template>
                     </ngx-datatable-column>
     </ngx-datatable>
        [![enter image description here][1]][1]

i need to update row one of the filed is "IsCompleted" = true when click on Checkbox. By defalult the incoming response of Iscompleted is"false".

 changed(row: any, isChecked: any) {
            if (isChecked) {
                if (row.FromQty !== row.ReceivedQty) {
                    this.alertService.warnAlert('Issued Quantity and Recieved Quantity Does not match');
                   this.accepted = false;
                } else if (row.FromWgt !==  row.ReceivedWgt) {
                    this.alertService.warnAlert('Issued Weight and Recieved Weight Does not match');
                } else {
                   for (let index = 0; index < this.stockInDataList.length; index++) {
                     if (this.stockInDataList[index].ProductId === row.ProductId) {
                        this.stockInDataList[index].IsCompleted = true;
                   }
                 }
                 this.stockInDataList = [...this.stockInDataList];
               }
            } else {
                for (let index = 0; index < this.stockInDataList.length; index++) {
                     if (this.stockInDataList[index].ProductId === row.ProductId) {
                        this.stockInDataList[index].IsCompleted = false;
                        }
                      }
                      this.stockInDataList = [...this.stockInDataList];
                    }
            }

so hear functionality working fine. after if condion is true im displying exception message after that i need uncheck that checkbox. but its not happening. so please suggest me. and also lookin how to bind with check and unchecked rows to bind table ?




Aucun commentaire:

Enregistrer un commentaire