# AdvanceGridComponent

**Kind:** Class

**Source:** `Pams/Web/Pams.Web/Client/app/components/shared/advance-grid/advance-grid.component.ts` (line 22)

**Part of:** [Pams](subsystem-pams)

`AdvanceGridComponent` manages grid pagination, page navigation, and grid-related callbacks in the shared client component layer. It initializes page state, handles cell updates, and checks whether processing is active before performing related actions.

**Implements:** `OnInit`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `ngOnInit` | `ngOnInit()` | `void` |
| `setPages` | `setPages(goToLastPage: boolean)` | `void` |
| `checkFullPage` | `checkFullPage(index: undefined)` | `boolean` |
| `goToPage` | `goToPage(index: number)` | `void` |
| `prevPage` | `prevPage()` | `void` |
| `nextPage` | `nextPage()` | `void` |
| `visibleAddNew` | `visibleAddNew()` | `void` |
| `checkCallback` | `checkCallback(button: PopOverButtonData)` | `void` |
| `cellUpdated_Handler` | `cellUpdated_Handler(e: undefined)` | `void` |
| `CallisProcessActive` | `CallisProcessActive(accessList: undefined, acessStatusId: undefined)` | `void` |
| `onDocumentKeyUp` | `onDocumentKeyUp(event: undefined)` | `void` |
| `onDocumentClick` | `onDocumentClick(event: undefined)` | `void` |
| `closeAllRequest_Handler` | `closeAllRequest_Handler(e: undefined)` | `void` |
| `selectAllRows` | `selectAllRows(e: undefined)` | `void` |
| `rowSelectedRequest_Handler` | `rowSelectedRequest_Handler(row: undefined)` | `void` |
| `rowOutputPopOverClicked_Handler` | `rowOutputPopOverClicked_Handler(e: undefined)` | `void` |
| `customizeSelect_allbutton` | `customizeSelect_allbutton()` | `void` |
| `PopoverSingleRowClick` | `PopoverSingleRowClick(e: undefined)` | `void` |
| `Popover_Click` | `Popover_Click(status: undefined, bool: undefined)` | `void` |
| `IsUnitized` | `IsUnitized()` | `void` |
| `unitizedRequested_Click` | `unitizedRequested_Click()` | `void` |
| `packageRequested_Click` | `packageRequested_Click()` | `void` |
| `splitRequested_Click` | `splitRequested_Click()` | `void` |
| `splitSingleClick` | `splitSingleClick(e: undefined)` | `void` |
| `unitizedSingleClick` | `unitizedSingleClick(e: undefined)` | `void` |
| `packageSingleClick` | `packageSingleClick(e: undefined)` | `void` |
| `selectedHasPackage` | `selectedHasPackage()` | `boolean` |
| `selectedHasItemized` | `selectedHasItemized()` | `boolean` |
| `showPackageUnitizeDependOnSelectedRows` | `showPackageUnitizeDependOnSelectedRows(checkType: string)` | `void` |
| `deleteRowRequest_Handler` | `deleteRowRequest_Handler(rowIndex: number)` | `void` |
| `deleteMultiRows` | `deleteMultiRows()` | `void` |
| `saveRowManually_Handler` | `saveRowManually_Handler(row: undefined)` | `void` |
| `addNewRow` | `addNewRow(e: CellItemEvent)` | `void` |
| `nextCellRequest_Handler` | `nextCellRequest_Handler(e: CellItemEvent)` | `void` |
| `isDisabled` | `isDisabled(rowIndex: number, index: number)` | `void` |
| `getNextRowNumber` | `getNextRowNumber(rowIndex: number, index: number)` | `void` |
| `rowHovered_Handler` | `rowHovered_Handler(rowIndex: number)` | `void` |
| `setFocusedRow` | `setFocusedRow(rowIndex: number)` | `void` |
| `openEdit` | `openEdit(rowIndex: number)` | `void` |
| `closeEdit` | `closeEdit()` | `void` |
| `colSpanCount` | `colSpanCount()` | `void` |
| `ngOnDestroy` | `ngOnDestroy()` | `void` |
| `OnOpenedPopup` | `OnOpenedPopup()` | `void` |
| `openPopup` | `openPopup(n: string, t: string, i: string, btnTxt: string)` | `void` |
| `savePopup` | `savePopup()` | `void` |
| `closePopup` | `closePopup()` | `void` |
| `ClosewithDonotSave` | `ClosewithDonotSave()` | `void` |
| `onDataImported` | `onDataImported(e: undefined)` | `void` |
| `importHandler` | `importHandler()` | `void` |
| `selectText` | `selectText(e: undefined)` | `void` |

## Properties

| Property | Type |
|---|---|
| `sampleSelectBox` | `ElementRef` |
| `rowComponents` | `QueryList<AdvRowComponent>` |
| `sharedPopup` | `SharedPopupComponent` |
| `splitRowComponent` | `SplitRowComponent` |
| `focusedRow` | `AdvRowComponent` |
| `focusedRowIndex` | `number` |
| `_columns` | `BehaviorSubject<AdvColumn[]>` |
| `_dataSource` | `BehaviorSubject<any[]>` |
| `readOnly` | `boolean` |
| `maxRows` | `number` |
| `highlightedRowIndex` | `number` |
| `colWidth` | `string` |
| `rowHeight` | `string` |
| `serialEnabled` | `boolean` |
| `selectEnabled` | `boolean` |
| `selectAllEnabled` | `boolean` |
| `deleteColumnEnabled` | `boolean` |
| `actionsDropdownEnabled` | `boolean` |
| `deleteManuallyHandled` | `boolean` |
| `allowDeleteRow` | `boolean` |
| `saveColumnEnabled` | `boolean` |
| `headerVisible` | `boolean` |
| `handlerEnabled` | `boolean` |
| `statusEnabled` | `boolean` |
| `addButton` | `addButton` |
| `serialField` | `string` |
| `splittedEnabled` | `boolean` |
| `splittedSerialField` | `string` |
| `selectField` | `string` |
| `keyField` | `string` |
| `cssClass` | `string` |
| `isProcessActive` | `boolean` |
| `disabledTriggerField` | `string` |
| `hidePackageUnitizeSwitch` | `boolean` |
| `ImportOption` | `any` |
| `_PopOverButtons` | `BehaviorSubject<PopOverButtonData[]>` |
| `newRowRequested` | `EventEmitter<any>` |
| `unitizedRequested` | `EventEmitter<any>` |
| `packageRequested` | `EventEmitter<any>` |
| `splitRequested` | `EventEmitter<any>` |
| `RowChecked` | `EventEmitter<any>` |
| `OutputPopOverArray` | `EventEmitter<any[]>` |
| `OutputPopOverClicked` | `EventEmitter<any[]>` |
| `parameterOfisProcessActive` | `EventEmitter<any>` |
| `cellUpdated` | `EventEmitter<any>` |
| `deleteRowRequest` | `any` |
| `deleteMultiRowsRequest` | `any` |
| `saveRowRequest` | `any` |
| `onImported` | `any` |
| `applySplitRows` | `any` |

## Where it refuses work

- `AdvanceGridComponent` stops the work with an early return when `this.isDisabled(rowIndex, index)`, in 2 places.
- `AdvanceGridComponent` stops the work with an early return when `this.datasourcePages[index].length > this.pageSize`.
- `AdvanceGridComponent` stops the work with an early return when `!this.addButton`.
- `AdvanceGridComponent` stops the work with an early return when `this.addButton.displayLogic`.
- `AdvanceGridComponent` stops the work with an early return when `button.DisplayCallback`.
- `AdvanceGridComponent` stops the work with an early return when `e.value != false && !e.value`.

## Diagram

```mermaid
graph LR
  Init[ngOnInit] --> Pages[setPages]
  Pages --> FullPage[checkFullPage]
  FullPage --> Navigation[goToPage]
  Navigation --> Previous[prevPage]
  Navigation --> Next[nextPage]
  Grid[AdvanceGridComponent] --> AddNew[visibleAddNew]
  Grid --> Callback[checkCallback]
  Grid --> CellUpdate[cellUpdated_Handler]
  Grid --> ProcessState[CallisProcessActive]
```

## Usage

```ts
import { AdvanceGridComponent } from './advance-grid.component';

export class GridToolbarComponent {
  constructor(private readonly grid: AdvanceGridComponent) {}

  showPreviousPage(): void {
    this.grid.prevPage();
  }

  showNextPage(): void {
    if (!this.grid.checkFullPage()) {
      this.grid.nextPage();
    }
  }

  refreshPages(): void {
    this.grid.setPages();
    this.grid.goToPage();
  }

  handleGridCellUpdate(): void {
    this.grid.cellUpdated_Handler();
  }
}
```

## AI Coding Instructions

- Let Angular call `ngOnInit()` through the component lifecycle; do not call it directly from application code.
- Call `setPages()` when the underlying grid data or paging state changes before navigating pages.
- Check `checkFullPage()` before advancing when page capacity affects navigation behavior.
- Keep callback and cell-update handling routed through `checkCallback()` and `cellUpdated_Handler()` rather than duplicating grid update logic.
- Check `CallisProcessActive()` before starting actions that should not run while grid processing is active.

## Used by

9 references from 9 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (9)

- `TranslateHandler` — `Pams/Web/Pams.Web/Client/app/app.module.ts`:1
- `ProcurementInquiryComponent` — `Pams/Web/Pams.Web/Client/app/components/procurement/procurement-details/procurement-inquiry/procurement-inquiry.component.ts`:1
- `ProcurementOfferComponent` — `Pams/Web/Pams.Web/Client/app/components/procurement/procurement-details/procurement-offer/procurement-offer.component.ts`:1
- `ProcurementOrderComponent` — `Pams/Web/Pams.Web/Client/app/components/procurement/procurement-details/procurement-order/procurement-order.component.ts`:1
- `PurchasingInquiryComponent` — `Pams/Web/Pams.Web/Client/app/components/purchasing/purchasing-details/purchasing-inquiry/purchasing-inquiry.component.ts`:1
- `PurchasingOfferComponent` — `Pams/Web/Pams.Web/Client/app/components/purchasing/purchasing-details/purchasing-offer/purchasing-offer.component.ts`:1
- `PurchasingOrderComponent` — `Pams/Web/Pams.Web/Client/app/components/purchasing/purchasing-details/purchasing-order/purchasing-order.component.ts`:1
- `OrderPanelDetailsComponent` — `Pams/Web/Pams.Web/Client/app/components/sales/new-job/order-panel-details/order-panel-details.component.ts`:1

…and 1 more.
