배율을 자동으로 재기Measure the scale automatically
scale: 'auto'는 그리드가 스스로 화면 폭과 배치 폭의 비를 재요. 부모 배율이 자주 바뀌는 화면에서는 값을 알려 줄 필요가 없어요. getScale()로 지금 잰 값을 볼 수 있어요.scale: 'auto' makes the grid measure the ratio of screen width to layout width itself, so a screen whose parent factor keeps changing needs no value. getScale() returns the measured factor.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<button type="button" id="z50">부모 50%</button>
<button type="button" id="z75">부모 75%</button>
<button type="button" id="z100">부모 100%</button>
<button type="button" id="now">지금 배율</button>
</div>
<div id="grid" style="height: 340px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('z50').addEventListener('click', () => actions.z50(api));
document.getElementById('z75').addEventListener('click', () => actions.z75(api));
document.getElementById('z100').addEventListener('click', () => actions.z100(api));
document.getElementById('now').addEventListener('click', () => actions.now(api));export const options = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'team', title: '팀', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `사원 ${i + 1}`,
team: ['개발', '디자인', '영업'][i % 3],
})),
rowKey: 'id',
scale: 'auto',
};
let say = () => { };
let holder = null;
export function setup(api, log) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null)
holder.style.cssText = '';
};
}
function zoom(api, factor) {
if (holder === null)
return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say({ ko: `부모 배율 ${factor}`, en: `Parent factor ${factor}` });
void api;
}
export const actions = {
z50: (api) => zoom(api, 0.5),
z75: (api) => zoom(api, 0.75),
z100: (api) => zoom(api, 1),
now: (api) => {
const value = Math.round(api.getScale() * 100) / 100;
say({ ko: `잰 배율 ${value}`, en: `Measured scale ${value}` });
},
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>배율을 자동으로 재기</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="z50">부모 50%</button>
<button type="button" id="z75">부모 75%</button>
<button type="button" id="z100">부모 100%</button>
<button type="button" id="now">지금 배율</button>
</div>
<div id="grid" style="height: 340px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const options = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'team', title: '팀', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `사원 ${i + 1}`,
team: ['개발', '디자인', '영업'][i % 3],
})),
rowKey: 'id',
scale: 'auto',
};
let say = () => { };
let holder = null;
function setup(api, log) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null)
holder.style.cssText = '';
};
}
function zoom(api, factor) {
if (holder === null)
return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say({ ko: `부모 배율 ${factor}`, en: `Parent factor ${factor}` });
void api;
}
const actions = {
z50: (api) => zoom(api, 0.5),
z75: (api) => zoom(api, 0.75),
z100: (api) => zoom(api, 1),
now: (api) => {
const value = Math.round(api.getScale() * 100) / 100;
say({ ko: `잰 배율 ${value}`, en: `Measured scale ${value}` });
},
};
options.ariaLabel = "배율을 자동으로 재기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('z50').addEventListener('click', () => actions.z50(api));
document.getElementById('z75').addEventListener('click', () => actions.z75(api));
document.getElementById('z100').addEventListener('click', () => actions.z100(api));
document.getElementById('now').addEventListener('click', () => actions.now(api));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.z50(api)}
>부모 50%</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.z75(api)}
>부모 75%</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.z100(api)}
>부모 100%</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.now(api)}
>지금 배율</button>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
team: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'team', title: '팀', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `사원 ${i + 1}`,
team: ['개발', '디자인', '영업'][i % 3] as string,
})),
rowKey: 'id',
scale: 'auto',
};
let say: (message: LogText) => void = () => {};
let holder: HTMLElement | null = null;
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null) holder.style.cssText = '';
};
}
function zoom(api: GridApi<Row>, factor: number): void {
if (holder === null) return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say({ ko: `부모 배율 ${factor}`, en: `Parent factor ${factor}` });
void api;
}
export const actions = {
z50: (api: GridApi<Row>) => zoom(api, 0.5),
z75: (api: GridApi<Row>) => zoom(api, 0.75),
z100: (api: GridApi<Row>) => zoom(api, 1),
now: (api: GridApi<Row>) => {
const value = Math.round(api.getScale() * 100) / 100;
say({ ko: `잰 배율 ${value}`, en: `Measured scale ${value}` });
},
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.z50(api)">부모 50%</button>
<button type="button" :disabled="!api" @click="api && actions.z75(api)">부모 75%</button>
<button type="button" :disabled="!api" @click="api && actions.z100(api)">부모 100%</button>
<button type="button" :disabled="!api" @click="api && actions.now(api)">지금 배율</button>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
team: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'team', title: '팀', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `사원 ${i + 1}`,
team: ['개발', '디자인', '영업'][i % 3] as string,
})),
rowKey: 'id',
scale: 'auto',
};
let say: (message: LogText) => void = () => {};
let holder: HTMLElement | null = null;
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null) holder.style.cssText = '';
};
}
function zoom(api: GridApi<Row>, factor: number): void {
if (holder === null) return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say({ ko: `부모 배율 ${factor}`, en: `Parent factor ${factor}` });
void api;
}
export const actions = {
z50: (api: GridApi<Row>) => zoom(api, 0.5),
z75: (api: GridApi<Row>) => zoom(api, 0.75),
z100: (api: GridApi<Row>) => zoom(api, 1),
now: (api: GridApi<Row>) => {
const value = Math.round(api.getScale() * 100) / 100;
say({ ko: `잰 배율 ${value}`, en: `Measured scale ${value}` });
},
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.z50(api)"
>부모 50%</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.z75(api)"
>부모 75%</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.z100(api)"
>부모 100%</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.now(api)"
>지금 배율</button>
</div>
<mx-grid style="height: 340px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
team: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'team', title: '팀', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `사원 ${i + 1}`,
team: ['개발', '디자인', '영업'][i % 3] as string,
})),
rowKey: 'id',
scale: 'auto',
};
let say: (message: LogText) => void = () => {};
let holder: HTMLElement | null = null;
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null) holder.style.cssText = '';
};
}
function zoom(api: GridApi<Row>, factor: number): void {
if (holder === null) return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say({ ko: `부모 배율 ${factor}`, en: `Parent factor ${factor}` });
void api;
}
export const actions = {
z50: (api: GridApi<Row>) => zoom(api, 0.5),
z75: (api: GridApi<Row>) => zoom(api, 0.75),
z100: (api: GridApi<Row>) => zoom(api, 1),
now: (api: GridApi<Row>) => {
const value = Math.round(api.getScale() * 100) / 100;
say({ ko: `잰 배율 ${value}`, en: `Measured scale ${value}` });
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<button type="button" id="z50">Parent 50%</button>
<button type="button" id="z75">Parent 75%</button>
<button type="button" id="z100">Parent 100%</button>
<button type="button" id="now">Current scale</button>
</div>
<div id="grid" style="height: 340px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('z50').addEventListener('click', () => actions.z50(api));
document.getElementById('z75').addEventListener('click', () => actions.z75(api));
document.getElementById('z100').addEventListener('click', () => actions.z100(api));
document.getElementById('now').addEventListener('click', () => actions.now(api));export const options = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'team', title: 'Team', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Employee ${i + 1}`,
team: ['Dev', 'Design', 'Sales'][i % 3],
})),
rowKey: 'id',
scale: 'auto',
};
let say = () => { };
let holder = null;
export function setup(api, log) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null)
holder.style.cssText = '';
};
}
function zoom(api, factor) {
if (holder === null)
return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say(`Parent factor ${factor}`);
void api;
}
export const actions = {
z50: (api) => zoom(api, 0.5),
z75: (api) => zoom(api, 0.75),
z100: (api) => zoom(api, 1),
now: (api) => {
const value = Math.round(api.getScale() * 100) / 100;
say(`Measured scale ${value}`);
},
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Measure the scale automatically</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="z50">Parent 50%</button>
<button type="button" id="z75">Parent 75%</button>
<button type="button" id="z100">Parent 100%</button>
<button type="button" id="now">Current scale</button>
</div>
<div id="grid" style="height: 340px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const options = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'team', title: 'Team', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Employee ${i + 1}`,
team: ['Dev', 'Design', 'Sales'][i % 3],
})),
rowKey: 'id',
scale: 'auto',
};
let say = () => { };
let holder = null;
function setup(api, log) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null)
holder.style.cssText = '';
};
}
function zoom(api, factor) {
if (holder === null)
return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say(`Parent factor ${factor}`);
void api;
}
const actions = {
z50: (api) => zoom(api, 0.5),
z75: (api) => zoom(api, 0.75),
z100: (api) => zoom(api, 1),
now: (api) => {
const value = Math.round(api.getScale() * 100) / 100;
say(`Measured scale ${value}`);
},
};
options.ariaLabel = "Measure the scale automatically";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('z50').addEventListener('click', () => actions.z50(api));
document.getElementById('z75').addEventListener('click', () => actions.z75(api));
document.getElementById('z100').addEventListener('click', () => actions.z100(api));
document.getElementById('now').addEventListener('click', () => actions.now(api));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.z50(api)}
>Parent 50%</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.z75(api)}
>Parent 75%</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.z100(api)}
>Parent 100%</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.now(api)}
>Current scale</button>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
name: string;
team: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'team', title: 'Team', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Employee ${i + 1}`,
team: ['Dev', 'Design', 'Sales'][i % 3] as string,
})),
rowKey: 'id',
scale: 'auto',
};
let say: (message: LogText) => void = () => {};
let holder: HTMLElement | null = null;
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null) holder.style.cssText = '';
};
}
function zoom(api: GridApi<Row>, factor: number): void {
if (holder === null) return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say(`Parent factor ${factor}`);
void api;
}
export const actions = {
z50: (api: GridApi<Row>) => zoom(api, 0.5),
z75: (api: GridApi<Row>) => zoom(api, 0.75),
z100: (api: GridApi<Row>) => zoom(api, 1),
now: (api: GridApi<Row>) => {
const value = Math.round(api.getScale() * 100) / 100;
say(`Measured scale ${value}`);
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.z50(api)">Parent 50%</button>
<button type="button" :disabled="!api" @click="api && actions.z75(api)">Parent 75%</button>
<button type="button" :disabled="!api" @click="api && actions.z100(api)">Parent 100%</button>
<button type="button" :disabled="!api" @click="api && actions.now(api)">Current scale</button>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
name: string;
team: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'team', title: 'Team', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Employee ${i + 1}`,
team: ['Dev', 'Design', 'Sales'][i % 3] as string,
})),
rowKey: 'id',
scale: 'auto',
};
let say: (message: LogText) => void = () => {};
let holder: HTMLElement | null = null;
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null) holder.style.cssText = '';
};
}
function zoom(api: GridApi<Row>, factor: number): void {
if (holder === null) return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say(`Parent factor ${factor}`);
void api;
}
export const actions = {
z50: (api: GridApi<Row>) => zoom(api, 0.5),
z75: (api: GridApi<Row>) => zoom(api, 0.75),
z100: (api: GridApi<Row>) => zoom(api, 1),
now: (api: GridApi<Row>) => {
const value = Math.round(api.getScale() * 100) / 100;
say(`Measured scale ${value}`);
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.z50(api)"
>Parent 50%</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.z75(api)"
>Parent 75%</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.z100(api)"
>Parent 100%</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.now(api)"
>Current scale</button>
</div>
<mx-grid style="height: 340px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
export interface Row {
id: number;
name: string;
team: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'team', title: 'Team', width: 120 },
],
rows: Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Employee ${i + 1}`,
team: ['Dev', 'Design', 'Sales'][i % 3] as string,
})),
rowKey: 'id',
scale: 'auto',
};
let say: (message: LogText) => void = () => {};
let holder: HTMLElement | null = null;
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
holder = api.getGridElement().parentElement;
return () => {
if (holder !== null) holder.style.cssText = '';
};
}
function zoom(api: GridApi<Row>, factor: number): void {
if (holder === null) return;
holder.style.transform = `scale(${factor})`;
holder.style.transformOrigin = 'top left';
holder.style.width = `${100 / factor}%`;
say(`Parent factor ${factor}`);
void api;
}
export const actions = {
z50: (api: GridApi<Row>) => zoom(api, 0.5),
z75: (api: GridApi<Row>) => zoom(api, 0.75),
z100: (api: GridApi<Row>) => zoom(api, 1),
now: (api: GridApi<Row>) => {
const value = Math.round(api.getScale() * 100) / 100;
say(`Measured scale ${value}`);
},
};