2 * Collection of grid related classses and interfaces.
4 import {TemplateRef, EventEmitter} from '@angular/core';
5 import {Observable, Subscription} from 'rxjs';
6 import {IdlService, IdlObject} from '@eg/core/idl.service';
7 import {OrgService} from '@eg/core/org.service';
8 import {ServerStoreService} from '@eg/core/server-store.service';
9 import {FormatService} from '@eg/core/format.service';
10 import {Pager} from '@eg/share/util/pager';
12 const MAX_ALL_ROW_COUNT = 10000;
14 export class GridColumn {
23 // IDL class of the object which contains this field.
24 // Not to be confused with the class of a linked object.
28 datePlusTime: boolean;
29 cellTemplate: TemplateRef<any>;
32 isDragTarget: boolean;
34 isMultiSortable: boolean;
35 disableTooltip: boolean;
36 comparator: (valueA: any, valueB: any) => number;
38 // True if the column was automatically generated.
41 flesher: (obj: any, col: GridColumn, item: any) => any;
43 getCellContext(row: any) {
47 userContext: this.cellContext
52 export class GridColumnSet {
53 columns: GridColumn[];
55 indexColumn: GridColumn;
57 isMultiSortable: boolean;
58 stockVisible: string[];
60 defaultHiddenFields: string[];
61 defaultVisibleFields: string[];
63 constructor(idl: IdlService, idlClass?: string) {
66 this.stockVisible = [];
67 this.idlClass = idlClass;
70 add(col: GridColumn) {
72 this.applyColumnDefaults(col);
74 if (!this.insertColumn(col)) {
75 // Column was rejected as a duplicate.
79 if (col.isIndex) { this.indexColumn = col; }
81 // track which fields are visible on page load.
83 this.stockVisible.push(col.name);
86 this.applyColumnSortability(col);
89 // Returns true if the new column was inserted, false otherwise.
90 // Declared columns take precedence over auto-generated columns
91 // when collisions occur.
92 // Declared columns are inserted in front of auto columns.
93 insertColumn(col: GridColumn): boolean {
96 if (this.getColByName(col.name)) {
97 // New auto-generated column conflicts with existing
101 // No collisions. Add to the end of the list
102 this.columns.push(col);
107 // Adding a declared column.
110 for (let idx = 0; idx < this.columns.length; idx++) {
111 const testCol = this.columns[idx];
112 if (testCol.name === col.name) { // match found
113 if (testCol.isAuto) {
114 // new column takes precedence, remove the existing column.
115 this.columns.splice(idx, 1);
118 // New column does not take precedence. Avoid
125 // Delcared columns are inserted just before the first auto-column
126 for (let idx = 0; idx < this.columns.length; idx++) {
127 const testCol = this.columns[idx];
128 if (testCol.isAuto) {
130 this.columns.unshift(col);
132 this.columns.splice(idx - 1, 0, col);
138 // No insertion point found. Toss the new column on the end.
139 this.columns.push(col);
143 getColByName(name: string): GridColumn {
144 return this.columns.filter(c => c.name === name)[0];
147 idlInfoFromDotpath(dotpath: string): any {
148 if (!dotpath || !this.idlClass) { return null; }
152 let idlClass = this.idl.classes[this.idlClass];
154 const pathParts = dotpath.split(/\./);
156 for (let i = 0; i < pathParts.length; i++) {
157 const part = pathParts[i];
158 idlParent = idlField;
159 idlField = idlClass.field_map[part];
162 if (idlField['class'] && (
163 idlField.datatype === 'link' ||
164 idlField.datatype === 'org_unit')) {
165 idlClass = this.idl.classes[idlField['class']];
173 idlParent: idlParent,
181 this.columns.forEach(col => {
185 col.visible = this.stockVisible.includes(col.name);
189 applyColumnDefaults(col: GridColumn) {
191 if (!col.idlFieldDef && col.path) {
192 const idlInfo = this.idlInfoFromDotpath(col.path);
194 col.idlFieldDef = idlInfo.idlField;
195 col.idlClass = idlInfo.idlClass.name;
197 col.label = col.idlFieldDef.label || col.idlFieldDef.name;
198 col.datatype = col.idlFieldDef.datatype;
203 if (!col.name) { col.name = col.path; }
204 if (!col.flex) { col.flex = 2; }
205 if (!col.align) { col.align = 'left'; }
206 if (!col.label) { col.label = col.name; }
207 if (!col.datatype) { col.datatype = 'text'; }
209 col.visible = !col.hidden;
212 applyColumnSortability(col: GridColumn) {
213 // column sortability defaults to the sortability of the column set.
214 if (col.isSortable === undefined && this.isSortable) {
215 col.isSortable = true;
218 if (col.isMultiSortable === undefined && this.isMultiSortable) {
219 col.isMultiSortable = true;
222 if (col.isMultiSortable) {
223 col.isSortable = true;
227 displayColumns(): GridColumn[] {
228 return this.columns.filter(c => c.visible);
231 insertBefore(source: GridColumn, target: GridColumn) {
234 this.columns.forEach((col, idx) => {
235 if (col.name === target.name) { targetIdx = idx; }});
237 this.columns.forEach((col, idx) => {
238 if (col.name === source.name) { sourceIdx = idx; }});
240 if (sourceIdx >= 0) {
241 this.columns.splice(sourceIdx, 1);
244 this.columns.splice(targetIdx, 0, source);
247 // Move visible columns to the front of the list.
248 moveVisibleToFront() {
249 const newCols = this.displayColumns();
250 this.columns.forEach(col => {
251 if (!col.visible) { newCols.push(col); }});
252 this.columns = newCols;
255 moveColumn(col: GridColumn, diff: number) {
256 let srcIdx, targetIdx;
258 this.columns.forEach((c, i) => {
259 if (c.name === col.name) { srcIdx = i; }
262 targetIdx = srcIdx + diff;
265 } else if (targetIdx >= this.columns.length) {
266 // Target index follows the last visible column.
268 this.columns.forEach((c, idx) => {
269 if (c.visible) { lastVisible = idx; }
272 // When moving a column (down) causes one or more
273 // visible columns to shuffle forward, our column
274 // moves into the slot of the last visible column.
275 // Otherwise, put it into the slot directly following
276 // the last visible column.
277 targetIdx = srcIdx <= lastVisible ? lastVisible : lastVisible + 1;
280 // Splice column out of old position, insert at new position.
281 this.columns.splice(srcIdx, 1);
282 this.columns.splice(targetIdx, 0, col);
285 compileSaveObject(): GridColumnPersistConf[] {
286 // only store information about visible columns.
287 // scrunch the data down to just the needed info.
288 return this.displayColumns().map(col => {
289 const c: GridColumnPersistConf = {name : col.name};
290 if (col.align !== 'left') { c.align = col.align; }
291 if (col.flex !== 2) { c.flex = Number(col.flex); }
292 if (Number(col.sort)) { c.sort = Number(c.sort); }
297 applyColumnSettings(conf: GridColumnPersistConf[]) {
299 if (!conf || conf.length === 0) {
300 // No configuration is available, but we have a list of
301 // fields to show or hide by default
303 if (this.defaultVisibleFields) {
304 this.columns.forEach(col => {
305 if (this.defaultVisibleFields.includes(col.name)) {
312 } else if (this.defaultHiddenFields) {
313 this.defaultHiddenFields.forEach(name => {
314 const col = this.getColByName(name);
326 conf.forEach(colConf => {
327 const col = this.getColByName(colConf.name);
328 if (!col) { return; } // no such column in this grid.
331 if (colConf.align) { col.align = colConf.align; }
332 if (colConf.flex) { col.flex = Number(colConf.flex); }
333 if (colConf.sort) { col.sort = Number(colConf.sort); }
335 // Add to new columns array, avoid dupes.
336 if (newCols.filter(c => c.name === col.name).length === 0) {
341 // columns which are not expressed within the saved
342 // configuration are marked as non-visible and
343 // appended to the end of the new list of columns.
344 this.columns.forEach(c => {
345 if (conf.filter(cf => cf.name === c.name).length === 0) {
351 this.columns = newCols;
356 export class GridRowSelector {
357 indexes: {[string: string]: boolean};
363 // Returns true if all of the requested indexes exist in the selector.
364 contains(index: string | string[]): boolean {
365 const indexes = [].concat(index);
366 for (let i = 0; i < indexes.length; i++) { // early exit
367 if (!this.indexes[indexes[i]]) {
374 select(index: string | string[]) {
375 const indexes = [].concat(index);
376 indexes.forEach(i => this.indexes[i] = true);
379 deselect(index: string | string[]) {
380 const indexes = [].concat(index);
381 indexes.forEach(i => delete this.indexes[i]);
384 // Returns the list of selected index values.
385 // in some contexts (template checkboxes) the value for an index is
386 // set to false to deselect instead of having it removed (via deselect()).
388 return Object.keys(this.indexes).filter(
389 ind => Boolean(this.indexes[ind]));
393 return this.selected().length === 0;
401 export interface GridRowFlairEntry {
402 icon: string; // name of material icon
403 title?: string; // tooltip string
406 export class GridColumnPersistConf {
413 export class GridPersistConf {
416 columns: GridColumnPersistConf[];
419 export class GridContext {
424 isMultiSortable: boolean;
425 useLocalSort: boolean;
427 disableMultiSelect: boolean;
428 disableSelect: boolean;
429 dataSource: GridDataSource;
430 columnSet: GridColumnSet;
431 rowSelector: GridRowSelector;
432 toolbarButtons: GridToolbarButton[];
433 toolbarCheckboxes: GridToolbarCheckbox[];
434 toolbarActions: GridToolbarAction[];
435 lastSelectedIndex: any;
436 pageChanges: Subscription;
437 rowFlairIsEnabled: boolean;
438 rowFlairCallback: (row: any) => GridRowFlairEntry;
439 rowClassCallback: (row: any) => string;
440 cellClassCallback: (row: any, col: GridColumn) => string;
441 defaultVisibleFields: string[];
442 defaultHiddenFields: string[];
443 overflowCells: boolean;
444 showLinkSelectors: boolean;
446 // Allow calling code to know when the select-all-rows-in-page
447 // action has occurred.
448 selectRowsInPageEmitter: EventEmitter<void>;
450 // Services injected by our grid component
453 store: ServerStoreService;
454 format: FormatService;
459 store: ServerStoreService,
460 format: FormatService) {
465 this.format = format;
466 this.pager = new Pager();
467 this.pager.limit = 10;
468 this.rowSelector = new GridRowSelector();
469 this.toolbarButtons = [];
470 this.toolbarCheckboxes = [];
471 this.toolbarActions = [];
475 this.selectRowsInPageEmitter = new EventEmitter<void>();
476 this.columnSet = new GridColumnSet(this.idl, this.idlClass);
477 this.columnSet.isSortable = this.isSortable === true;
478 this.columnSet.isMultiSortable = this.isMultiSortable === true;
479 this.columnSet.defaultHiddenFields = this.defaultHiddenFields;
480 this.columnSet.defaultVisibleFields = this.defaultVisibleFields;
481 this.generateColumns();
484 // Load initial settings and data.
486 this.applyGridConfig()
487 .then(ok => this.dataSource.requestPage(this.pager))
488 .then(ok => this.listenToPager());
495 applyGridConfig(): Promise<void> {
496 return this.getGridConfig(this.persistKey)
500 columns = conf.columns;
502 this.pager.limit = conf.limit;
506 // This is called regardless of the presence of saved
507 // settings so defaults can be applied.
508 this.columnSet.applyColumnSettings(columns);
513 // Give the UI time to settle before reloading grid data.
514 // This can help when data retrieval depends on a value
515 // getting modified by an angular digest cycle.
518 this.dataSource.reset();
519 this.dataSource.requestPage(this.pager);
523 // Sort the existing data source instead of requesting sorted
524 // data from the client. Reset pager to page 1. As with reload(),
525 // give the client a chance to setting before redisplaying.
529 this.sortLocalData();
530 this.dataSource.requestPage(this.pager);
534 // Subscribe or unsubscribe to page-change events from the pager.
536 if (this.pageChanges) { return; }
537 this.pageChanges = this.pager.onChange$.subscribe(
538 val => this.dataSource.requestPage(this.pager));
542 if (!this.pageChanges) { return; }
543 this.pageChanges.unsubscribe();
544 this.pageChanges = null;
547 // Sort data in the data source array
550 const sortDefs = this.dataSource.sort.map(sort => {
551 const column = this.columnSet.getColByName(sort.name);
559 if (!def.col.comparator) {
560 switch (def.col.datatype) {
564 def.col.comparator = (a, b) => {
567 if (a < b) { return -1; }
568 if (a > b) { return 1; }
573 def.col.comparator = (a, b) => {
574 if (a < b) { return -1; }
575 if (a > b) { return 1; }
584 this.dataSource.data.sort((rowA, rowB) => {
586 for (let idx = 0; idx < sortDefs.length; idx++) {
587 const sortDef = sortDefs[idx];
589 const valueA = this.getRowColumnValue(rowA, sortDef.col);
590 const valueB = this.getRowColumnValue(rowB, sortDef.col);
592 if (valueA === '' && valueB === '') { continue; }
593 if (valueA === '' && valueB !== '') { return 1; }
594 if (valueA !== '' && valueB === '') { return -1; }
596 const diff = sortDef.col.comparator(valueA, valueB);
597 if (diff === 0) { continue; }
599 return sortDef.dir === 'DESC' ? -diff : diff;
602 return 0; // No differences found.
606 getRowIndex(row: any): any {
607 const col = this.columnSet.indexColumn;
609 throw new Error('grid index column required');
611 return this.getRowColumnValue(row, col);
614 // Returns position in the data source array of the row with
615 // the provided index.
616 getRowPosition(index: any): number {
617 // for-loop for early exit
618 for (let idx = 0; idx < this.dataSource.data.length; idx++) {
619 const row = this.dataSource.data[idx];
620 if (row !== undefined && index === this.getRowIndex(row)) {
626 // Return the row with the provided index.
627 getRowByIndex(index: any): any {
628 for (let idx = 0; idx < this.dataSource.data.length; idx++) {
629 const row = this.dataSource.data[idx];
630 if (row !== undefined && index === this.getRowIndex(row)) {
636 // Returns all selected rows, regardless of whether they are
637 // currently visible in the grid display.
638 getSelectedRows(): any[] {
640 this.rowSelector.selected().forEach(index => {
641 const row = this.getRowByIndex(index);
649 getRowColumnValue(row: any, col: GridColumn): string {
653 val = this.nestedItemFieldValue(row, col);
654 } else if (col.name in row) {
655 val = this.getObjectFieldValue(row, col.name);
658 return this.format.transform({
660 idlClass: col.idlClass,
661 idlField: col.idlFieldDef ? col.idlFieldDef.name : col.name,
662 datatype: col.datatype,
663 datePlusTime: Boolean(col.datePlusTime)
667 getObjectFieldValue(obj: any, name: string): any {
668 if (typeof obj[name] === 'function') {
675 nestedItemFieldValue(obj: any, col: GridColumn): string {
679 const original = obj;
680 const steps = col.path.split('.');
682 for (let i = 0; i < steps.length; i++) {
683 const step = steps[i];
685 if (obj === null || obj === undefined || typeof obj !== 'object') {
686 // We have run out of data to step through before
687 // reaching the end of the path. Conclude fleshing via
688 // callback if provided then exit.
689 if (col.flesher && obj !== undefined) {
690 return col.flesher(obj, col, original);
695 const class_ = obj.classname;
696 if (class_ && (idlClassDef = this.idl.classes[class_])) {
697 idlField = idlClassDef.field_map[step];
700 obj = this.getObjectFieldValue(obj, step);
703 // We found a nested IDL object which may or may not have
704 // been configured as a top-level column. Flesh the column
705 // metadata with our newly found IDL info.
708 col.datatype = idlField.datatype;
710 if (!col.idlFieldDef) {
711 idlField = col.idlFieldDef;
714 col.idlClass = idlClassDef.name;
717 col.label = idlField.label || idlField.name;
725 getColumnTextContent(row: any, col: GridColumn): string {
726 if (col.cellTemplate) {
728 // Extract the text content from the rendered template.
730 return this.getRowColumnValue(row, col);
734 selectOneRow(index: any) {
735 this.rowSelector.clear();
736 this.rowSelector.select(index);
737 this.lastSelectedIndex = index;
740 selectMultipleRows(indexes: any[]) {
741 this.rowSelector.clear();
742 this.rowSelector.select(indexes);
743 this.lastSelectedIndex = indexes[indexes.length - 1];
746 // selects or deselects an item, without affecting the others.
747 // returns true if the item is selected; false if de-selected.
748 toggleSelectOneRow(index: any) {
749 if (this.rowSelector.contains(index)) {
750 this.rowSelector.deselect(index);
754 this.rowSelector.select(index);
758 selectRowByPos(pos: number) {
759 const row = this.dataSource.data[pos];
761 this.selectOneRow(this.getRowIndex(row));
765 selectPreviousRow() {
766 if (!this.lastSelectedIndex) { return; }
767 const pos = this.getRowPosition(this.lastSelectedIndex);
768 if (pos === this.pager.offset) {
769 this.toPrevPage().then(ok => this.selectLastRow(), err => {});
771 this.selectRowByPos(pos - 1);
776 if (!this.lastSelectedIndex) { return; }
777 const pos = this.getRowPosition(this.lastSelectedIndex);
778 if (pos === (this.pager.offset + this.pager.limit - 1)) {
779 this.toNextPage().then(ok => this.selectFirstRow(), err => {});
781 this.selectRowByPos(pos + 1);
786 // Select the previous row in addition to any currently selected row.
787 // However, if the previous row is already selected, assume the user
788 // has reversed direction and now wants to de-select the last selected row.
789 selectMultiRowsPrevious() {
790 if (!this.lastSelectedIndex) { return; }
791 const pos = this.getRowPosition(this.lastSelectedIndex);
792 const selectedIndexes = this.rowSelector.selected();
794 const promise = // load the previous page of data if needed
795 (pos === this.pager.offset) ? this.toPrevPage() : Promise.resolve();
799 const row = this.dataSource.data[pos - 1];
800 const newIndex = this.getRowIndex(row);
801 if (selectedIndexes.filter(i => i === newIndex).length > 0) {
802 // Prev row is already selected. User is reversing direction.
803 this.rowSelector.deselect(this.lastSelectedIndex);
804 this.lastSelectedIndex = newIndex;
806 this.selectMultipleRows(selectedIndexes.concat(newIndex));
814 // Select the next row in addition to any currently selected row.
815 // However, if the next row is already selected, assume the user
816 // has reversed direction and wants to de-select the last selected row.
817 selectMultiRowsNext() {
818 if (!this.lastSelectedIndex) { return; }
819 const pos = this.getRowPosition(this.lastSelectedIndex);
820 const selectedIndexes = this.rowSelector.selected();
822 const promise = // load the next page of data if needed
823 (pos === (this.pager.offset + this.pager.limit - 1)) ?
824 this.toNextPage() : Promise.resolve();
828 const row = this.dataSource.data[pos + 1];
829 const newIndex = this.getRowIndex(row);
830 if (selectedIndexes.filter(i => i === newIndex).length > 0) {
831 // Next row is already selected. User is reversing direction.
832 this.rowSelector.deselect(this.lastSelectedIndex);
833 this.lastSelectedIndex = newIndex;
835 this.selectMultipleRows(selectedIndexes.concat(newIndex));
842 getFirstRowInPage(): any {
843 return this.dataSource.data[this.pager.offset];
846 getLastRowInPage(): any {
847 return this.dataSource.data[this.pager.offset + this.pager.limit - 1];
851 this.selectOneRow(this.getRowIndex(this.getFirstRowInPage()));
855 this.selectOneRow(this.getRowIndex(this.getLastRowInPage()));
859 const rows = this.dataSource.getPageOfRows(this.pager);
860 const indexes = rows.map(r => this.getRowIndex(r));
861 this.rowSelector.select(indexes);
862 this.selectRowsInPageEmitter.emit();
865 toPrevPage(): Promise<any> {
866 if (this.pager.isFirstPage()) {
867 return Promise.reject('on first');
869 // temp ignore pager events since we're calling requestPage manually.
871 this.pager.decrement();
872 this.listenToPager();
873 return this.dataSource.requestPage(this.pager);
876 toNextPage(): Promise<any> {
877 if (this.pager.isLastPage()) {
878 return Promise.reject('on last');
880 // temp ignore pager events since we're calling requestPage manually.
882 this.pager.increment();
883 this.listenToPager();
884 return this.dataSource.requestPage(this.pager);
887 getAllRows(): Promise<any> {
888 const pager = new Pager();
890 pager.limit = MAX_ALL_ROW_COUNT;
891 return this.dataSource.requestPage(pager);
894 // Returns a key/value pair object of visible column data as text.
895 getRowAsFlatText(row: any): any {
897 this.columnSet.displayColumns().forEach(col => {
899 this.getColumnTextContent(row, col);
904 getAllRowsAsText(): Observable<any> {
905 return Observable.create(observer => {
906 this.getAllRows().then(ok => {
907 this.dataSource.data.forEach(row => {
908 observer.next(this.getRowAsFlatText(row));
915 gridToCsv(): Promise<string> {
918 const columns = this.columnSet.displayColumns();
921 columns.forEach(col => {
922 csvStr += this.valueToCsv(col.label),
926 csvStr = csvStr.replace(/,$/, '\n');
928 return new Promise(resolve => {
929 this.getAllRowsAsText().subscribe(
931 columns.forEach(col => {
932 csvStr += this.valueToCsv(row[col.name]);
935 csvStr = csvStr.replace(/,$/, '\n');
938 () => resolve(csvStr)
944 // prepares a string for inclusion within a CSV document
945 // by escaping commas and quotes and removing newlines.
946 valueToCsv(str: string): string {
948 if (!str) { return ''; }
949 str = str.replace(/\n/g, '');
950 if (str.match(/\,/) || str.match(/"/)) {
951 str = str.replace(/"/g, '""');
952 str = '"' + str + '"';
958 if (!this.columnSet.idlClass) { return; }
960 const pkeyField = this.idl.classes[this.columnSet.idlClass].pkey;
962 // generate columns for all non-virtual fields on the IDL class
963 this.idl.classes[this.columnSet.idlClass].fields
964 .filter(field => !field.virtual)
966 const col = new GridColumn();
967 col.name = field.name;
968 col.label = field.label || field.name;
969 col.idlFieldDef = field;
970 col.idlClass = this.columnSet.idlClass;
971 col.datatype = field.datatype;
972 col.isIndex = (field.name === pkeyField);
975 if (this.showLinkSelectors) {
976 const selector = this.idl.getLinkSelector(
977 this.columnSet.idlClass, field.name);
979 col.path = field.name + '.' + selector;
983 this.columnSet.add(col);
987 saveGridConfig(): Promise<any> {
988 if (!this.persistKey) {
989 throw new Error('Grid persistKey required to save columns');
991 const conf = new GridPersistConf();
993 conf.limit = this.pager.limit;
994 conf.columns = this.columnSet.compileSaveObject();
996 return this.store.setItem('eg.grid.' + this.persistKey, conf);
999 // TODO: saveGridConfigAsOrgSetting(...)
1001 getGridConfig(persistKey: string): Promise<GridPersistConf> {
1002 if (!persistKey) { return Promise.resolve(null); }
1003 return this.store.getItem('eg.grid.' + persistKey);
1008 // Actions apply to specific rows
1009 export class GridToolbarAction {
1011 onClick: EventEmitter<any []>;
1012 action: (rows: any[]) => any; // DEPRECATED
1014 isGroup: boolean; // used for group placeholder entries
1015 disableOnRows: (rows: any[]) => boolean;
1018 // Buttons are global actions
1019 export class GridToolbarButton {
1021 onClick: EventEmitter<any []>;
1022 action: () => any; // DEPRECATED
1026 export class GridToolbarCheckbox {
1029 onChange: EventEmitter<boolean>;
1032 export class GridDataSource {
1036 allRowsRetrieved: boolean;
1037 requestingData: boolean;
1038 getRows: (pager: Pager, sort: any[]) => Observable<any>;
1047 this.allRowsRetrieved = false;
1050 // called from the template -- no data fetching
1051 getPageOfRows(pager: Pager): any[] {
1053 return this.data.slice(
1054 pager.offset, pager.limit + pager.offset
1055 ).filter(row => row !== undefined);
1060 // called on initial component load and user action (e.g. paging, sorting).
1061 requestPage(pager: Pager): Promise<any> {
1064 this.getPageOfRows(pager).length === pager.limit
1065 // already have all data
1066 || this.allRowsRetrieved
1067 // have no way to get more data.
1070 return Promise.resolve();
1073 // If we have to call out for data, set inFetch
1074 this.requestingData = true;
1076 return new Promise((resolve, reject) => {
1077 let idx = pager.offset;
1078 return this.getRows(pager, this.sort).subscribe(
1080 this.data[idx++] = row;
1081 this.requestingData = false;
1084 console.error(`grid getRows() error ${err}`);
1088 this.checkAllRetrieved(pager, idx);
1089 this.requestingData = false;
1096 // See if the last getRows() call resulted in the final set of data.
1097 checkAllRetrieved(pager: Pager, idx: number) {
1098 if (this.allRowsRetrieved) { return; }
1100 if (idx === 0 || idx < (pager.limit + pager.offset)) {
1101 // last query returned nothing or less than one page.
1102 // confirm we have all of the preceding pages.
1103 if (!this.data.includes(undefined)) {
1104 this.allRowsRetrieved = true;
1105 pager.resultCount = this.data.length;