RTL에서 고정 컬럼과 끌기 쓰기Pinned columns and dragging in RTL
direction: 'rtl'에서 행 끌기 손잡이, 셀 범위 끌기, 채우기 핸들, 시작 쪽 고정 컬럼이 오른쪽부터 같은 방식으로 동작해요.With direction: 'rtl' the row drag handle, cell range dragging, the fill handle and the start-side pinned column work the same way, starting from the right.
코드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="select">담당 2칸 선택</button>
</div>
<div id="grid" style="height: 330px"></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('select').addEventListener('click', () => actions.select(api));const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4],
note: '',
}));
// RTL에서도 손잡이 칸, 셀 범위 끌기·채우기 핸들, 고정 컬럼이 같은 방식으로 동작해요. 손잡이는 시작 쪽(오른쪽)에 놓이고
// 채우기 핸들은 선택 범위의 끝 쪽(왼쪽 아래) 모서리에 나타나요.
export const options = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api, log) {
log({
ko: '오른쪽 손잡이(⠿)로 행을 옮기고, 칸 몇 개를 골라 핸들을 끌어 채워 보세요. 모두 RTL 방향으로 동작해요.',
en: 'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
});
const offs = [
api.on('rowDropped', (e) => log({ ko: `행 이동: ${e.keys.join(', ')}`, en: `Rows moved: ${e.keys.join(', ')}` })),
api.on('fillEnded', (e) => log({ ko: `채움: ${e.count}칸`, en: `Filled: ${e.count} cells` })),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api) => api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>RTL에서 고정 컬럼과 끌기 쓰기</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="select">담당 2칸 선택</button>
</div>
<div id="grid" style="height: 330px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4],
note: '',
}));
// RTL에서도 손잡이 칸, 셀 범위 끌기·채우기 핸들, 고정 컬럼이 같은 방식으로 동작해요. 손잡이는 시작 쪽(오른쪽)에 놓이고
// 채우기 핸들은 선택 범위의 끝 쪽(왼쪽 아래) 모서리에 나타나요.
const options = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
function setup(api, log) {
log({
ko: '오른쪽 손잡이(⠿)로 행을 옮기고, 칸 몇 개를 골라 핸들을 끌어 채워 보세요. 모두 RTL 방향으로 동작해요.',
en: 'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
});
const offs = [
api.on('rowDropped', (e) => log({ ko: `행 이동: ${e.keys.join(', ')}`, en: `Rows moved: ${e.keys.join(', ')}` })),
api.on('fillEnded', (e) => log({ ko: `채움: ${e.count}칸`, en: `Filled: ${e.count} cells` })),
];
return () => offs.forEach((off) => off());
}
const actions = {
select: (api) => api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};
options.ariaLabel = "RTL에서 고정 컬럼과 끌기 쓰기";
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('select').addEventListener('click', () => actions.select(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.select(api)}
>담당 2칸 선택</button>
</div>
<Grid style={{ height: 330 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
note: string;
}
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows: Row[] = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4] as string,
note: '',
}));
// RTL에서도 손잡이 칸, 셀 범위 끌기·채우기 핸들, 고정 컬럼이 같은 방식으로 동작해요. 손잡이는 시작 쪽(오른쪽)에 놓이고
// 채우기 핸들은 선택 범위의 끝 쪽(왼쪽 아래) 모서리에 나타나요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '오른쪽 손잡이(⠿)로 행을 옮기고, 칸 몇 개를 골라 핸들을 끌어 채워 보세요. 모두 RTL 방향으로 동작해요.',
en: 'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
});
const offs = [
api.on('rowDropped', (e) =>
log({ ko: `행 이동: ${e.keys.join(', ')}`, en: `Rows moved: ${e.keys.join(', ')}` }),
),
api.on('fillEnded', (e) => log({ ko: `채움: ${e.count}칸`, en: `Filled: ${e.count} cells` })),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api: GridApi<Row>) =>
api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};버튼을 누르면 이 예제의 코드가 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.select(api)">담당 2칸 선택</button>
</div>
<Grid style="height: 330px" :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;
task: string;
owner: string;
note: string;
}
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows: Row[] = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4] as string,
note: '',
}));
// RTL에서도 손잡이 칸, 셀 범위 끌기·채우기 핸들, 고정 컬럼이 같은 방식으로 동작해요. 손잡이는 시작 쪽(오른쪽)에 놓이고
// 채우기 핸들은 선택 범위의 끝 쪽(왼쪽 아래) 모서리에 나타나요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '오른쪽 손잡이(⠿)로 행을 옮기고, 칸 몇 개를 골라 핸들을 끌어 채워 보세요. 모두 RTL 방향으로 동작해요.',
en: 'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
});
const offs = [
api.on('rowDropped', (e) =>
log({ ko: `행 이동: ${e.keys.join(', ')}`, en: `Rows moved: ${e.keys.join(', ')}` }),
),
api.on('fillEnded', (e) => log({ ko: `채움: ${e.count}칸`, en: `Filled: ${e.count} cells` })),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api: GridApi<Row>) =>
api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};버튼을 누르면 이 예제의 코드가 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.select(api)"
>담당 2칸 선택</button>
</div>
<mx-grid style="height: 330px" [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;
task: string;
owner: string;
note: string;
}
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows: Row[] = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4] as string,
note: '',
}));
// RTL에서도 손잡이 칸, 셀 범위 끌기·채우기 핸들, 고정 컬럼이 같은 방식으로 동작해요. 손잡이는 시작 쪽(오른쪽)에 놓이고
// 채우기 핸들은 선택 범위의 끝 쪽(왼쪽 아래) 모서리에 나타나요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log({
ko: '오른쪽 손잡이(⠿)로 행을 옮기고, 칸 몇 개를 골라 핸들을 끌어 채워 보세요. 모두 RTL 방향으로 동작해요.',
en: 'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
});
const offs = [
api.on('rowDropped', (e) =>
log({ ko: `행 이동: ${e.keys.join(', ')}`, en: `Rows moved: ${e.keys.join(', ')}` }),
),
api.on('fillEnded', (e) => log({ ko: `채움: ${e.count}칸`, en: `Filled: ${e.count} cells` })),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api: GridApi<Row>) =>
api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};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="select">Select 2 owner cells</button>
</div>
<div id="grid" style="height: 330px"></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('select').addEventListener('click', () => actions.select(api));// The data and column titles stay Hebrew on purpose: this example is about the RTL direction.
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4],
note: '',
}));
// In RTL too, the handle cell, cell range dragging, the fill handle and pinned columns work the same way. The handle sits on the start side (right) and
// the fill handle appears at the end-side (bottom-left) corner of the selected range.
export const options = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api, log) {
log('Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.');
const offs = [
api.on('rowDropped', (e) => log(`Rows moved: ${e.keys.join(', ')}`)),
api.on('fillEnded', (e) => log(`Filled: ${e.count} cells`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api) => api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pinned columns and dragging in RTL</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="select">Select 2 owner cells</button>
</div>
<div id="grid" style="height: 330px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// The data and column titles stay Hebrew on purpose: this example is about the RTL direction.
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4],
note: '',
}));
// In RTL too, the handle cell, cell range dragging, the fill handle and pinned columns work the same way. The handle sits on the start side (right) and
// the fill handle appears at the end-side (bottom-left) corner of the selected range.
const options = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
function setup(api, log) {
log('Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.');
const offs = [
api.on('rowDropped', (e) => log(`Rows moved: ${e.keys.join(', ')}`)),
api.on('fillEnded', (e) => log(`Filled: ${e.count} cells`)),
];
return () => offs.forEach((off) => off());
}
const actions = {
select: (api) => api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};
options.ariaLabel = "Pinned columns and dragging in RTL";
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('select').addEventListener('click', () => actions.select(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.select(api)}
>Select 2 owner cells</button>
</div>
<Grid style={{ height: 330 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
task: string;
owner: string;
note: string;
}
// The data and column titles stay Hebrew on purpose: this example is about the RTL direction.
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows: Row[] = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4] as string,
note: '',
}));
// In RTL too, the handle cell, cell range dragging, the fill handle and pinned columns work the same way. The handle sits on the start side (right) and
// the fill handle appears at the end-side (bottom-left) corner of the selected range.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log(
'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
);
const offs = [
api.on('rowDropped', (e) => log(`Rows moved: ${e.keys.join(', ')}`)),
api.on('fillEnded', (e) => log(`Filled: ${e.count} cells`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api: GridApi<Row>) =>
api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};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.select(api)">Select 2 owner cells</button>
</div>
<Grid style="height: 330px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
task: string;
owner: string;
note: string;
}
// The data and column titles stay Hebrew on purpose: this example is about the RTL direction.
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows: Row[] = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4] as string,
note: '',
}));
// In RTL too, the handle cell, cell range dragging, the fill handle and pinned columns work the same way. The handle sits on the start side (right) and
// the fill handle appears at the end-side (bottom-left) corner of the selected range.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log(
'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
);
const offs = [
api.on('rowDropped', (e) => log(`Rows moved: ${e.keys.join(', ')}`)),
api.on('fillEnded', (e) => log(`Filled: ${e.count} cells`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api: GridApi<Row>) =>
api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};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.select(api)"
>Select 2 owner cells</button>
</div>
<mx-grid style="height: 330px" [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;
task: string;
owner: string;
note: string;
}
// The data and column titles stay Hebrew on purpose: this example is about the RTL direction.
const owners = ['אורי', 'נועה', 'דנה', 'איתן'];
const rows: Row[] = ['תכנון', 'עיצוב', 'פיתוח', 'בדיקות', 'תיעוד', 'הפצה'].map((task, i) => ({
id: i + 1,
task,
owner: owners[i % 4] as string,
note: '',
}));
// In RTL too, the handle cell, cell range dragging, the fill handle and pinned columns work the same way. The handle sits on the start side (right) and
// the fill handle appears at the end-side (bottom-left) corner of the selected range.
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'משימה', width: 160, pinned: 'start', editable: true },
{ id: 'owner', title: 'אחראי', width: 120, editable: true },
{ id: 'note', title: 'הערה', width: 180, editable: true },
],
direction: 'rtl',
selection: 'multiple',
cellSelection: 'multiple',
rowDrag: true,
cellDrag: true,
cellFill: true,
rows,
rowKey: 'id',
};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
log(
'Move rows with the handle (⠿) on the right, or select a few cells and drag the fill handle. Everything works in the RTL direction.',
);
const offs = [
api.on('rowDropped', (e) => log(`Rows moved: ${e.keys.join(', ')}`)),
api.on('fillEnded', (e) => log(`Filled: ${e.count} cells`)),
];
return () => offs.forEach((off) => off());
}
export const actions = {
select: (api: GridApi<Row>) =>
api.selectCells({ rowKey: 1, columnId: 'owner' }, { rowKey: 2, columnId: 'owner' }),
};