Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Material table with filter in each header

Im doing a table with materiwl where is required to have a filter input for each column on the header.
The code is below and the problem is that while triggering the input for searching the sorting is also trigered.

Its any way not to trigger sorting while try to insert into the input field.

https://stackblitz.com/edit/new-project-3gxwan?file=src%2Fapp%2Fshared%2Fcomponents%2Fformly-table-generic%2Ftable.ts,src%2Fapp%2Fproduct-data-fromAPI.ts

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

add this (click)="$event.stopPropagation();" on your filter input

<ng-container *ngIf="currentField.key != 'check';else second">
        <th mat-header-cell *matHeaderCellDef mat-sort-header>
          {{ currentField.name}}
          <input
            type="search"
            (click)="$event.stopPropagation();"
            (keyup)="filter($event.target.value, I)" (keydown.space)="$event.stopPropagation()"
          />
        </th>
        <td mat-cell *matCellDef="let element">
          <formly-field [field]="element.fieldGroup[i]"></formly-field>
        </td>
      </ng-container>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading