User Tools

Site Tools


newdevs:code:grid-cell-text-generator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
newdevs:code:grid-cell-text-generator [2023/03/30 16:59] – created tmccannanewdevs:code:grid-cell-text-generator [2023/12/21 16:54] tmccanna
Line 4: Line 4:
 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. 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 Barcode Field in Holds Pull List  =====+===== Example of the Title Field in Holds Pull List  =====
  
-1. The barcode field in staff/share/holds/grid.component.html is modified ng-template so that it links to the item page: +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: 
  
 <code> <code>
-<ng-template #barcodeTmpl let-hold="row" let-col="col"> +<ng-template #titleTmpl let-hold="row"> 
-    <a href="/eg/staff/cat/item/{{hold.cp_id}}/summary"> +    <a class="no-href" routerLink="/staff/catalog/record/{{hold.record_id}}"> 
-        <ng-container *ngIf="col.name == 'current_item' && hold.current_copy"> +        {{hold.title}}
-            {{hold.cp_barcode}} +
-        </ng-container> +
-        <ng-container *ngIf="col.name == 'requested_item' && isCopyHold(hold)"> +
-            {{hold.cp_barcode}} +
-        </ng-container>+
     </a>     </a>
 </ng-template> </ng-template>
-</code> 
  
-2. Below that, the grid column is defined:  +<eg-grid-column i18n-label label="Title" [hidden]="true" name='title
- +    [cellTemplate]="titleTmpl">
-<code> +
-<eg-grid-column i18n-label label="Current Item" name='current_item+
-    [cellTemplate]="barcodeTmpl">+
 </eg-grid-column> </eg-grid-column>
 </code> </code>
  
-3. The grid.component.ts file is modified to specify the alternate text that should print out: +2. The eg-grid tag must also include 
 +<code>[cellTextGenerator]="cellTextGenerator"</code> 
 + 
 +3. The grid.component.ts file must include the ability to use GridCellTextGenerator: 
 + 
 +<code>import {GridDataSource, GridColumn, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid';</code> 
 + 
 +and then inside the class:  
 + 
 +<code>cellTextGenerator: GridCellTextGenerator;</code> 
 + 
 +4. And then inside ngOnInit - the grid.component.ts file is modified to specify the alternate text that should print out: 
  
 <code> <code>
 this.cellTextGenerator = { this.cellTextGenerator = {
-    title: row => row.title+    title: row => row.title
-    cp_barcode: row => (row.cp_barcode == null) ? '' : row.cp_barcode, +
-    current_item: row => (row.cp_barcode == null) ? '' : row.cp_barcode, +
-    requested_item: row => (row.cp_barcode == null) ? '' : row.cp_barcode, +
-    ucard_barcode: row => row.ucard_barcode+
 }; };
 </code> </code>
 +
newdevs/code/grid-cell-text-generator.txt · Last modified: 2023/12/21 16:55 by tmccanna

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.