@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
60 lines (59 loc) • 2.14 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Injectable } from "@angular/core";
import * as i0 from "@angular/core";
// Registry to track active Grid instances and their indices
const activeGridIndices = new Set();
// Get the next available grid index (reuses freed indices)
function getNextGridIndex() {
let index = 0;
while (activeGridIndices.has(index)) {
index++;
}
activeGridIndices.add(index);
return index;
}
// Release a grid index when the Grid is destroyed
function releaseGridIndex(index) {
activeGridIndices.delete(index);
}
/**
* @hidden
*/
export class IdService {
prefix;
gridIndex;
columnCounter = 0;
constructor() {
this.gridIndex = getNextGridIndex();
this.prefix = `k-grid${this.gridIndex}`;
}
ngOnDestroy() {
releaseGridIndex(this.gridIndex);
}
gridId() {
return this.prefix;
}
cellId(rowIndex, colIndex) {
return `${this.prefix}-r${rowIndex}c${colIndex}`;
}
selectionCheckboxId(itemIndex) {
return `${this.prefix}-checkbox${itemIndex}`;
}
selectAllCheckboxId() {
return `${this.prefix}-select-all`;
}
columnId(colIndex) {
return `${this.prefix}-col${colIndex}`;
}
nextColumnId() {
return `${this.prefix}-col${this.columnCounter++}`;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IdService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IdService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: IdService, decorators: [{
type: Injectable
}], ctorParameters: () => [] });