// each mapped column on a given row. This is primarily useful for
// generating print-friendly content for grid cells rendered via
// cellTemplate.
+//
+// USAGE NOTE: Since a cellTemplate can be passed arbitrary context
+// but a GridCellTextGenerator only gets the row object,
+// if it's important to include content that's not available
+// by default in the row object, you may want to stick
+// it in the row object as an additional attribute.
+//
export interface GridCellTextGenerator {
[columnName: string]: (row: any) => string;
}
[rowFlairCallback]="btGridRowFlairCallback"
[cellClassCallback]="btGridCellClassCallback"
[stickyHeader]="true"
+ [cellTextGenerator]="btGridCellTextGenerator"
[sortable]="true">
<eg-grid-toolbar-action label="Action that needs a single row" i18n-label
(onClick)="complimentEvergreen($event)" [disableOnRows]="notOneSelectedRow">
import {ToastService} from '@eg/share/toast/toast.service';
import {StringService} from '@eg/share/string/string.service';
import {map, take} from 'rxjs/operators';
-import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid';
+import {GridDataSource, GridColumn, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid';
import {IdlService, IdlObject} from '@eg/core/idl.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {OrgService} from '@eg/core/org.service';
cbAsyncSource: (term: string) => Observable<ComboboxEntry>;
btSource: GridDataSource = new GridDataSource();
+ btGridCellTextGenerator: GridCellTextGenerator;
acpSource: GridDataSource = new GridDataSource();
eventsDataSource: GridDataSource = new GridDataSource();
editSelected: (rows: IdlObject[]) => void;
}));
};
+ // GridCellTextGenerator for the btGrid; note that this
+ // also demonstrates that a GridCellTextGenerator only has
+ // access to the row, and does not have access to any additional
+ // context that might be passed to a cellTemplate
+ this.btGridCellTextGenerator = {
+ test: row => 'HELLO universe ' + row.id()
+ };
+
this.acpSource.getRows = (pager: Pager, sort: any[]) => {
const orderBy: any = {acp: 'id'};
if (sort.length) {