라이선스 상태 확인하기 (평가 모드 표시)Check the license status (evaluation mode shown)
라이선스 키를 넣지 않아도 그리드는 평가 모드로 동작해요. 키가 확인되면 상태, 에디션, 이유를 알려 줘서 관리자 화면 같은 곳에서 직접 안내를 보여 줄 수 있어요. 이 갤러리의 번들은 개발자용이라 '유효, 개발용'으로 알려 와요.The grid runs in evaluation mode even without a license key. Once the key is checked it announces status, edition and reason, so you can show your own notice. This gallery's bundle is a developer build, so it reports valid and developer.
코드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 id="grid" style="height: 250px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);export const options = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 130 },
],
rows: [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
],
rowKey: 'id',
// 받은 키는 여기에 넣거나, 페이지에서 한 번만 MaxGrid.config({ licenseKey })로 정해요.
// licenseKey: 'MXG1.…',
};
// 키가 없어도 그리드는 동작해요(평가 모드). 이 이벤트가 어떤 상태인지 알려 주니,
// 관리자 화면 같은 곳에서 직접 안내 문구를 보여 줄 때 쓸 수 있어요.
// 이벤트로 오는 값(valid, developer 같은 영문 코드)을 한글로 풀어서 보여 줘요. 모르는 값은 그대로 적어요.
const STATUS = {
valid: '유효',
invalid: '유효하지 않음',
expired: '만료',
evaluation: '평가 중',
missing: '키 없음',
};
const EDITION = {
developer: '개발용',
standard: '표준',
enterprise: '기업용',
};
const STATUS_EN = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION_EN = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (map, value, none = '없음') => (value ? (map[value] ?? value) : none);
export function setup(api, log) {
log({
ko: '라이선스 상태 알림을 기다리는 중이에요',
en: 'Waiting for the license status notice',
});
return api.on('licenseStatusChanged', (e) => log({
ko: `상태 ${say(STATUS, e.status)}, 에디션 ${say(EDITION, e.edition)}, 이유 ${e.reason ?? '없음'}`,
en: `Status ${say(STATUS_EN, e.status, 'none')}, edition ${say(EDITION_EN, e.edition, 'none')}, reason ${e.reason ?? 'none'}`,
}));
}<!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 id="grid" style="height: 250px"></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: 150 },
{ id: 'dept', title: '부서', width: 130 },
],
rows: [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
],
rowKey: 'id',
// 받은 키는 여기에 넣거나, 페이지에서 한 번만 MaxGrid.config({ licenseKey })로 정해요.
// licenseKey: 'MXG1.…',
};
// 키가 없어도 그리드는 동작해요(평가 모드). 이 이벤트가 어떤 상태인지 알려 주니,
// 관리자 화면 같은 곳에서 직접 안내 문구를 보여 줄 때 쓸 수 있어요.
// 이벤트로 오는 값(valid, developer 같은 영문 코드)을 한글로 풀어서 보여 줘요. 모르는 값은 그대로 적어요.
const STATUS = {
valid: '유효',
invalid: '유효하지 않음',
expired: '만료',
evaluation: '평가 중',
missing: '키 없음',
};
const EDITION = {
developer: '개발용',
standard: '표준',
enterprise: '기업용',
};
const STATUS_EN = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION_EN = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (map, value, none = '없음') => (value ? (map[value] ?? value) : none);
function setup(api, log) {
log({
ko: '라이선스 상태 알림을 기다리는 중이에요',
en: 'Waiting for the license status notice',
});
return api.on('licenseStatusChanged', (e) => log({
ko: `상태 ${say(STATUS, e.status)}, 에디션 ${say(EDITION, e.edition)}, 이유 ${e.reason ?? '없음'}`,
en: `Status ${say(STATUS_EN, e.status, 'none')}, edition ${say(EDITION_EN, e.edition, 'none')}, reason ${e.reason ?? 'none'}`,
}));
}
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);
});
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<Grid style={{ height: 250 }} 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;
dept: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 130 },
],
rows: [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
],
rowKey: 'id',
// 받은 키는 여기에 넣거나, 페이지에서 한 번만 MaxGrid.config({ licenseKey })로 정해요.
// licenseKey: 'MXG1.…',
};
// 키가 없어도 그리드는 동작해요(평가 모드). 이 이벤트가 어떤 상태인지 알려 주니,
// 관리자 화면 같은 곳에서 직접 안내 문구를 보여 줄 때 쓸 수 있어요.
// 이벤트로 오는 값(valid, developer 같은 영문 코드)을 한글로 풀어서 보여 줘요. 모르는 값은 그대로 적어요.
const STATUS: Record<string, string> = {
valid: '유효',
invalid: '유효하지 않음',
expired: '만료',
evaluation: '평가 중',
missing: '키 없음',
};
const EDITION: Record<string, string> = {
developer: '개발용',
standard: '표준',
enterprise: '기업용',
};
const STATUS_EN: Record<string, string> = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION_EN: Record<string, string> = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (
map: Record<string, string>,
value: string | undefined | null,
none = '없음',
): string => (value ? (map[value] ?? value) : none);
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '라이선스 상태 알림을 기다리는 중이에요',
en: 'Waiting for the license status notice',
});
return api.on('licenseStatusChanged', (e) =>
log({
ko: `상태 ${say(STATUS, e.status)}, 에디션 ${say(EDITION, e.edition)}, 이유 ${e.reason ?? '없음'}`,
en: `Status ${say(STATUS_EN, e.status, 'none')}, edition ${say(EDITION_EN, e.edition, 'none')}, reason ${e.reason ?? 'none'}`,
}),
);
}버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { 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>
<Grid style="height: 250px" :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;
dept: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 130 },
],
rows: [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
],
rowKey: 'id',
// 받은 키는 여기에 넣거나, 페이지에서 한 번만 MaxGrid.config({ licenseKey })로 정해요.
// licenseKey: 'MXG1.…',
};
// 키가 없어도 그리드는 동작해요(평가 모드). 이 이벤트가 어떤 상태인지 알려 주니,
// 관리자 화면 같은 곳에서 직접 안내 문구를 보여 줄 때 쓸 수 있어요.
// 이벤트로 오는 값(valid, developer 같은 영문 코드)을 한글로 풀어서 보여 줘요. 모르는 값은 그대로 적어요.
const STATUS: Record<string, string> = {
valid: '유효',
invalid: '유효하지 않음',
expired: '만료',
evaluation: '평가 중',
missing: '키 없음',
};
const EDITION: Record<string, string> = {
developer: '개발용',
standard: '표준',
enterprise: '기업용',
};
const STATUS_EN: Record<string, string> = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION_EN: Record<string, string> = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (
map: Record<string, string>,
value: string | undefined | null,
none = '없음',
): string => (value ? (map[value] ?? value) : none);
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '라이선스 상태 알림을 기다리는 중이에요',
en: 'Waiting for the license status notice',
});
return api.on('licenseStatusChanged', (e) =>
log({
ko: `상태 ${say(STATUS, e.status)}, 에디션 ${say(EDITION, e.edition)}, 이유 ${e.reason ?? '없음'}`,
en: `Status ${say(STATUS_EN, e.status, 'none')}, edition ${say(EDITION_EN, e.edition, 'none')}, reason ${e.reason ?? 'none'}`,
}),
);
}버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 250px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
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;
dept: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150 },
{ id: 'dept', title: '부서', width: 130 },
],
rows: [
{ id: 1, name: '김민준', dept: '개발팀' },
{ id: 2, name: '이서연', dept: '디자인팀' },
{ id: 3, name: '박지호', dept: '영업팀' },
],
rowKey: 'id',
// 받은 키는 여기에 넣거나, 페이지에서 한 번만 MaxGrid.config({ licenseKey })로 정해요.
// licenseKey: 'MXG1.…',
};
// 키가 없어도 그리드는 동작해요(평가 모드). 이 이벤트가 어떤 상태인지 알려 주니,
// 관리자 화면 같은 곳에서 직접 안내 문구를 보여 줄 때 쓸 수 있어요.
// 이벤트로 오는 값(valid, developer 같은 영문 코드)을 한글로 풀어서 보여 줘요. 모르는 값은 그대로 적어요.
const STATUS: Record<string, string> = {
valid: '유효',
invalid: '유효하지 않음',
expired: '만료',
evaluation: '평가 중',
missing: '키 없음',
};
const EDITION: Record<string, string> = {
developer: '개발용',
standard: '표준',
enterprise: '기업용',
};
const STATUS_EN: Record<string, string> = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION_EN: Record<string, string> = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (
map: Record<string, string>,
value: string | undefined | null,
none = '없음',
): string => (value ? (map[value] ?? value) : none);
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '라이선스 상태 알림을 기다리는 중이에요',
en: 'Waiting for the license status notice',
});
return api.on('licenseStatusChanged', (e) =>
log({
ko: `상태 ${say(STATUS, e.status)}, 에디션 ${say(EDITION, e.edition)}, 이유 ${e.reason ?? '없음'}`,
en: `Status ${say(STATUS_EN, e.status, 'none')}, edition ${say(EDITION_EN, e.edition, 'none')}, reason ${e.reason ?? 'none'}`,
}),
);
}When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div id="grid" style="height: 250px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);export const options = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Department', width: 130 },
],
rows: [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Reed', dept: 'Sales' },
],
rowKey: 'id',
// Put the key you received here, or set it once on the page with MaxGrid.config({ licenseKey }).
// licenseKey: 'MXG1.…',
};
// The grid works without a key (evaluation mode). This event tells you the state,
// so you can use it to show your own notice text, for example on an admin screen.
// The English codes that arrive with the event (valid, developer and so on) are turned into readable words. Unknown values are written as they are.
const STATUS = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (map, value, none = 'none') => (value ? (map[value] ?? value) : none);
export function setup(api, log) {
log('Waiting for the license status notice');
return api.on('licenseStatusChanged', (e) => log(`Status ${say(STATUS, e.status)}, edition ${say(EDITION, e.edition)}, reason ${e.reason ?? 'none'}`));
}<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Check the license status (evaluation mode shown)</title>
</head>
<body>
<div id="grid" style="height: 250px"></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: 150 },
{ id: 'dept', title: 'Department', width: 130 },
],
rows: [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Reed', dept: 'Sales' },
],
rowKey: 'id',
// Put the key you received here, or set it once on the page with MaxGrid.config({ licenseKey }).
// licenseKey: 'MXG1.…',
};
// The grid works without a key (evaluation mode). This event tells you the state,
// so you can use it to show your own notice text, for example on an admin screen.
// The English codes that arrive with the event (valid, developer and so on) are turned into readable words. Unknown values are written as they are.
const STATUS = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (map, value, none = 'none') => (value ? (map[value] ?? value) : none);
function setup(api, log) {
log('Waiting for the license status notice');
return api.on('licenseStatusChanged', (e) => log(`Status ${say(STATUS, e.status)}, edition ${say(EDITION, e.edition)}, reason ${e.reason ?? 'none'}`));
}
options.ariaLabel = "Check the license status (evaluation mode shown)";
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);
});
</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 { options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<Grid style={{ height: 250 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
name: string;
dept: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Department', width: 130 },
],
rows: [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Reed', dept: 'Sales' },
],
rowKey: 'id',
// Put the key you received here, or set it once on the page with MaxGrid.config({ licenseKey }).
// licenseKey: 'MXG1.…',
};
// The grid works without a key (evaluation mode). This event tells you the state,
// so you can use it to show your own notice text, for example on an admin screen.
// The English codes that arrive with the event (valid, developer and so on) are turned into readable words. Unknown values are written as they are.
const STATUS: Record<string, string> = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION: Record<string, string> = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (
map: Record<string, string>,
value: string | undefined | null,
none = 'none',
): string => (value ? (map[value] ?? value) : none);
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Waiting for the license status notice');
return api.on('licenseStatusChanged', (e) =>
log(
`Status ${say(STATUS, e.status)}, edition ${say(EDITION, e.edition)}, reason ${e.reason ?? 'none'}`,
),
);
}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 { 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>
<Grid style="height: 250px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
name: string;
dept: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Department', width: 130 },
],
rows: [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Reed', dept: 'Sales' },
],
rowKey: 'id',
// Put the key you received here, or set it once on the page with MaxGrid.config({ licenseKey }).
// licenseKey: 'MXG1.…',
};
// The grid works without a key (evaluation mode). This event tells you the state,
// so you can use it to show your own notice text, for example on an admin screen.
// The English codes that arrive with the event (valid, developer and so on) are turned into readable words. Unknown values are written as they are.
const STATUS: Record<string, string> = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION: Record<string, string> = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (
map: Record<string, string>,
value: string | undefined | null,
none = 'none',
): string => (value ? (map[value] ?? value) : none);
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Waiting for the license status notice');
return api.on('licenseStatusChanged', (e) =>
log(
`Status ${say(STATUS, e.status)}, edition ${say(EDITION, e.edition)}, reason ${e.reason ?? 'none'}`,
),
);
}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 { options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 250px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
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;
dept: string;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150 },
{ id: 'dept', title: 'Department', width: 130 },
],
rows: [
{ id: 1, name: 'Liam Carter', dept: 'Dev' },
{ id: 2, name: 'Emma Stone', dept: 'Design' },
{ id: 3, name: 'Noah Reed', dept: 'Sales' },
],
rowKey: 'id',
// Put the key you received here, or set it once on the page with MaxGrid.config({ licenseKey }).
// licenseKey: 'MXG1.…',
};
// The grid works without a key (evaluation mode). This event tells you the state,
// so you can use it to show your own notice text, for example on an admin screen.
// The English codes that arrive with the event (valid, developer and so on) are turned into readable words. Unknown values are written as they are.
const STATUS: Record<string, string> = {
valid: 'valid',
invalid: 'invalid',
expired: 'expired',
evaluation: 'evaluation',
missing: 'no key',
};
const EDITION: Record<string, string> = {
developer: 'developer',
standard: 'standard',
enterprise: 'enterprise',
};
const say = (
map: Record<string, string>,
value: string | undefined | null,
none = 'none',
): string => (value ? (map[value] ?? value) : none);
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log('Waiting for the license status notice');
return api.on('licenseStatusChanged', (e) =>
log(
`Status ${say(STATUS, e.status)}, edition ${say(EDITION, e.edition)}, reason ${e.reason ?? 'none'}`,
),
);
}