1

Currently having an issue that when sort is clicked the column that has formControls in an array by row the data & controls are not updated correctly. All other columns are updating as expected. Below is the code that has the formControls:

<form [formGroup]="rackAverageForms[i]">
          <md-input-container>
            <input [formControl]="rackAverageForms[i].controls.rackAverage" #rackAverage
                   formControlName="rackAverage"
                   (keydown.tab)="validateRackAverage(rackAverage,i)" class="numeric-field" [numberOnly]="true"
                   mdInput value="{{row.chosenDateRackAverage | currency:'USD':true:'1.4-4'}}">
            <md-error><strong>{{formErrors[i].rackAverage}}</strong></md-error>
          </md-input-container>
</form>

Here is a screenshot of before sort: md-table view before trying to sort

This is after sorting and the data is gone: md-table view after sorting with missing data

Sometimes there is one value that will hang around, but most of the time all of the values in this column are gone and controls gone as well. Please help.

1 Answer 1

1

After trying a few different things, switching to using the row.id unique value to look up the formcontrol it is now working. See fixed html below:

       <form [formGroup]="rackAverageForms[row.id]">
          <ng-container *ngIf="row.chosenDateRackAverage > 0">
            <md-input-container>
              <input [formControl]="rackAverageForms[row.id].controls.rackAverage" #rackAverage
                     formControlName="rackAverage"
                     (keydown.tab)="validateRackAverage(rackAverage,row.id)" class="numeric-field" [numberOnly]="true"
                     mdInput value="{{row.chosenDateRackAverage | currency:'USD':true:'1.4-4'}}" >
              <md-error><strong>{{formErrors[row.id].rackAverage}}</strong></md-error>
            </md-input-container>
          </ng-container>
        </form>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.