@jsvision/datagrid / absoluteRect
Function: absoluteRect()
absoluteRect(
view):object
Defined in: datagrid/src/overlay.ts:56
A mounted view's absolute top-left, by summing parent-relative bounds.x/y up the tree (the root bounds are absolute). Use it to get the body's absolute origin to pass as origin to mountCellOverlay.
Parameters
view
View
A mounted view.
Returns
object
The view's absolute top-left cell { x, y }.
x
x:
number
y
y:
number
Example
ts
import { signal } from '@jsvision/ui';
import { column, fromRows, EditableDataGrid, absoluteRect } from '@jsvision/datagrid';
interface Row { id: number; name: string }
const rows = signal<Row[]>([{ id: 1, name: 'Ada' }]);
const columns = [column({ id: 'name', title: 'Name', value: (r: Row) => r.name })];
const grid = new EditableDataGrid<Row>({ columns, source: fromRows(rows, { rowKey: (r) => r.id }) });
// Given a mounted grid body view:
const origin = absoluteRect(grid.rows); // e.g. { x: 4, y: 3 }