0

I am using a form array to display the data and have a method to dynamically add rows in a table. I will check multiple rows from one table ASNlst and push it to other table ConnectedASNlst .This works fine. But having pagination implemented now when i try to check a row from second page (Ex: page 2 and row 3), i will still see page 1 and row 3 record moving from ASNlst to ConnectedASNlst. How to get the index value for dynamic reactive forms

I tried using slice but this did not work

 <tr formArrayName="ASNlst" *ngFor="let availableASN of
  lstAvailableASN | slice: (page-1) * pageSize : (page-1) * pageSize +
  pageSize ;let i = index;">

<form [formGroup]="form" (ngSubmit)="submitToConnect()">              
    <table class="table table-condensed">                  
        <tr formArrayName="ASNlst" *ngFor="let availableASN of lstAvailableASN ; let isCollapsed = true;let i = index;">                    
            <td>
                <input type="checkbox" [formControlName]="i" checked (change)="selChk(availableASN, i)" />
            </td>
            <td class=" form-control-sm">
                <div>
                    Supplier:
                    <b>{{availableASN.supplier}}</b>
                </div>
                <div>
                    ASN:
                    <b>{{availableASN.asnNumber}}</b>
                </div>
                <div>
                    ShipDateTime:
                    <b>{{availableASN.shipDate}}</b>
                </div>                      
            </td>
        </tr>
    </table>
    <button class="col-12 btn btn-secondary btn-sm" id="btnClearConnect" type="submit" [disabled]="form.invalid">Connect</button>
</form>

I should able to move the checked rows from all the pages from ASNlst to ConnectedASNlst. Basically How do I get the absolute index of a list item?

ramya m
  • 13
  • 1
  • 5
  • Please read [Formatting help](https://stackoverflow.com/editing-help) and try to improve the readability of your question. – Daan Jun 25 '19 at 08:08
  • 1
    I have made the changes. – ramya m Jun 25 '19 at 08:28
  • I also suggest you to look at your tags, `angular7` doesn't seem to have that many watchers. I personally don't use angular, but maybe changing it to a more popular (but still relevant) angular tag will help to gain useful traction towards your question. – Daan Jun 25 '19 at 08:44
  • I changed it to angular reactive forms – ramya m Jun 25 '19 at 08:54
  • I am trying to implement pagination using ngx-pagination – ramya m Jun 25 '19 at 09:04
  • I wouldn't suggest removing `angular7`, I meant to say to add `angular(js)`. For the same reason that you tag `html` instead of `html5` for example. More people will watch on just `html`. It'd be better to have both `html` and `html5` tagged. – Daan Jun 25 '19 at 10:06
  • I have made the change. Please help me with this – ramya m Jun 25 '19 at 15:00

0 Answers0