Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Accessing hidden fields in igx-grid field ng-template
posted

I am having trouble accessing hidden fields when crafting an anchor tag with a routerLink directive within an igx-grid field template. I'd like to get the current cell, then row and then a specific hidden cell in that row to craft the link queryParams. Specifically, I need to replace <<id>> in the code below.

<igx-grid #grid [data]="mydata" [primaryKey]="'id'" [autoGenerate]='false'>
      <igx-column field="id" header="ID" hidden="true" ></igx-column>
      <igx-column field="name" header="Name" sortable="true" >
          <ng-template igxCell let-cell="cell">
              <a [routerLink]="['/myroute', <<id>>]">{{ cell.value }}</a>
          </ng-template>
      </igx-column>
    </igx-grid>

Parents
No Data
Reply
  • 35
    Verified Answer
    Offline posted

    looks like I am able to access more data in the component typescript file.

    • I added a click listener to the grid: (onCellClick)="cellClick($event.cell)"
    • then changed the anchor tag and routerLink to: <a [routerLink]="">{{ cell.value }}</a>
    • and finally listened to the click event on the typescript file to grab the target cell and used angular router.navigate
    cellClick(cell: IgxGridCellComponent) {
        if (cell.column.field == 'name')
            this.router.navigate(['/myroute', {id: cell.row.rowData.id}]);
    }
Children