New Developers Working Group

Grid Cell Text Generator

When a grid cell (aka, column) is modified to include HTML such as a link, it will not print when printing the full grid unless you take the additional step of telling the system what to print.

Example of the Title Field in Holds Pull List

1. An ng-template block in in staff/share/holds/grid.component.html is created to turn the title column into a link to the record page:

<ng-template #titleTmpl let-hold="row">
    <a class="no-href" routerLink="/staff/catalog/record/{{hold.record_id}}">
        {{hold.title}}
    </a>
</ng-template>

<eg-grid-column i18n-label label="Title" [hidden]="true" name='title'
    [cellTemplate]="titleTmpl">
</eg-grid-column>

2. The eg-grid tag should include

[cellTextGenerator]="cellTextGenerator"

3. The grid.component.ts file must include the ability to use GridCellTextGenerator:

import {GridDataSource, GridColumn, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid';

and then inside the class:

cellTextGenerator: GridCellTextGenerator;

4. And then inside ngOnInit - the grid.component.ts file is modified to specify the alternate text that should print out:

this.cellTextGenerator = {
    title: row => row.title
};