// Used in conjunction with cellTemplate
@Input() cellContext: any;
@Input() cellTemplate: TemplateRef<any>;
+ @Input() cellPrintValue: (row: any, cell: GridColumn) => string;
@Input() disableTooltip: boolean;
col.hidden = this.hidden === true;
col.isIndex = this.index === true;
col.cellTemplate = this.cellTemplate;
+ col.cellPrintValue = this.cellPrintValue;
col.cellContext = this.cellContext;
col.disableTooltip = this.disableTooltip;
col.isSortable = this.sortable;
ternaryBool: boolean;
timezoneContextOrg: number;
cellTemplate: TemplateRef<any>;
+
+ // Provide a way for cells that are generated via cellTemplate's
+ // to provide an alternate text value suitable for printing.
+ cellPrintValue: (row: any, cell: GridColumn) => string;
+
cellContext: any;
isIndex: boolean;
isDragTarget: boolean;
getColumnTextContent(row: any, col: GridColumn): string {
- if (col.cellTemplate) {
- // TODO
- // Extract the text content from the rendered template.
+ if (col.cellPrintValue) {
+ return col.cellPrintValue(row, col);
} else {
- return this.getRowColumnValue(row, col);
+ if (col.cellTemplate) {
+ return ''; // avoid 'undefined' values
+ } else {
+ return this.getRowColumnValue(row, col);
+ }
}
}
</eg-grid-column>
<eg-grid-column i18n-label label="Location" path="circ_lib" datatype="org_unit">
</eg-grid-column>
- <eg-grid-column i18n-label label="Call Number / Item Notes"
- name="callnumber" [cellTemplate]="cnTemplate">
+ <eg-grid-column i18n-label label="Call Number / Item Notes" name="callnumber"
+ [cellTemplate]="cnTemplate" [cellPrintValue]="cellPrintValues">
</eg-grid-column>
<eg-grid-column i18n-label label="Barcode" name="barcode"
- [cellTemplate]="barcodeTemplate">
+ [cellTemplate]="barcodeTemplate" [cellPrintValue]="cellPrintValues">
</eg-grid-column>
<eg-grid-column i18n-label label="Shelving Location" path="copy_location">
</eg-grid-column>
path="active_date" datatype="timestamp">
</eg-grid-column>
<eg-grid-column i18n-label label="Holdable?" name="holdable"
- [cellTemplate]="holdableTemplate" [cellContext]="copyContext">
+ [cellTemplate]="holdableTemplate" [cellContext]="copyContext"
+ [cellPrintValue]="cellPrintValues">
</eg-grid-column>
<eg-grid-column i18n-label label="Status" path="copy_status">
</eg-grid-column>
import {StaffCatalogService} from '../catalog.service';
import {Pager} from '@eg/share/util/pager';
import {OrgService} from '@eg/core/org.service';
-import {GridDataSource} from '@eg/share/grid/grid';
+import {GridDataSource, GridColumn} from '@eg/share/grid/grid';
import {GridComponent} from '@eg/share/grid/grid.component';
@Component({
}
}
+ cellPrintValues: (row: any, cell: GridColumn) => string;
+
constructor(
private net: NetService,
private org: OrgService,
&& copy.status_holdable === 't';
}
};
+
+ // Text-ify function for cells that use display templates.
+ this.cellPrintValues = (row: any, cell: GridColumn): string => {
+ switch (cell.name) {
+ case 'callnumber':
+ return `${row.call_number_prefix_label} ` +
+ `${row.call_number_label} ${row.call_number_suffix_label}`;
+ case 'holdable':
+ return this.copyContext.holdable(row);
+ case 'barcode':
+ return row.barcode;
+ }
+ };
}
collectData() {