// would go out of view
@Input() stickyHeader: boolean;
+ // Array of row index values. Rows with the provided indexes
+ // will be marked as selected in the grid once they are loaded.
+ // Rows are only marked as selected at load time, at which point
+ // the grid's selection logic takes over.
+ @Input() selectRowsOnLoad: any[] = [];
+
context: GridContext;
// These events are emitted from our grid-body component.
this.context.showDeclaredFieldsOnly = this.showDeclaredFieldsOnly;
this.context.rowFlairCallback = this.rowFlairCallback;
this.context.disablePaging = this.disablePaging === true;
+ this.context.selectRowsOnLoad = this.selectRowsOnLoad;
+
if (this.showFields) {
this.context.defaultVisibleFields = this.showFields.split(',');
}
showLinkSelectors: boolean;
disablePaging: boolean;
showDeclaredFieldsOnly: boolean;
+ selectRowsOnLoad: any[] = [];
// Allow calling code to know when the select-all-rows-in-page
// action has occurred.
this.generateColumns();
}
+ // Watch for pages of data as they arrive so we can analyze.
+ onDataSourcePageLoad() {
+ if (this.selectRowsOnLoad.length) {
+ // Select a row from selectRowsOnLoad exactly once and only
+ // after the row has been fetched. Note rows will retain
+ // selection through page navigation. They will only be cleared
+ // if the data source is reset. Note the rows must be selected
+ // in this manner, because this.getSelectedRows performs
+ // maintenance on the rowSelector, deleting selections for
+ // rows which have been deleted (or not yet retrieved).
+ const selected = [];
+ const pending = [];
+ this.selectRowsOnLoad.forEach(index => {
+ if (this.getRowByIndex(index)) {
+ selected.push(index);
+ } else {
+ pending.push(index);
+ }
+ });
+ this.rowSelector.select(selected);
+ this.selectRowsOnLoad = pending;
+ }
+ }
+
// Load initial settings and data.
initData() {
+ this.dataSource.onPageLoaded.subscribe(_ => this.onDataSourcePageLoad());
+
this.applyGridConfig()
.then(ok => this.dataSource.requestPage(this.pager))
.then(ok => this.listenToPager());
allRowsRetrieved: boolean;
requestingData: boolean;
getRows: (pager: Pager, sort: any[]) => Observable<any>;
+ onPageLoaded: EventEmitter<any> = new EventEmitter<any>();
constructor() {
this.sort = [];
// called on initial component load and user action (e.g. paging, sorting).
requestPage(pager: Pager): Promise<any> {
+ return this.requestPageBody(pager).then(_ => this.onPageLoaded.emit());
+ }
+
+ requestPageBody(pager: Pager): Promise<any> {
if (
this.getPageOfRows(pager).length === pager.limit
persistKey="cat.vandelay.queue.{{queueType}}"
(onRowActivate)="openRecord($event)"
[pageOffset]="queuePageOffset()"
+ [selectRowsOnLoad]="selectRowsOnLoad"
hideFields="language,pagination,price,rec_identifier,eg_tcn_source,eg_identifier,item_barcode,zsource">
<eg-grid-toolbar-checkbox i18n-label label="Records With Matches"
queueSource: GridDataSource;
queuedRecClass: string;
queueSummary: any;
+ selectRowsOnLoad: any[] = [];
filters = {
matches: false,
}
ngOnInit() {
+
+ if (this.vandelay.importSelection) {
+ // If a queued record has a merge/overlay target selected,
+ // make sure the queued record is also marked as selected
+ // for processing.
+ this.selectRowsOnLoad =
+ Object.keys(this.vandelay.importSelection.overlayMap);
+ }
}
limitToMatches(checked: boolean) {