오른쪽에서 왼쪽으로 보기(RTL)Right-to-left layout (RTL)
direction: 'rtl'이면 컬럼이 오른쪽부터 놓이고 가로 스크롤, 고정 컬럼, ← → 키, 끌기 방향이 모두 뒤집혀요. 'auto'는 컨테이너의 CSS direction을 따르고 기본은 왼쪽에서 오른쪽이에요.With direction: 'rtl' columns start on the right, and horizontal scrolling, pinned columns, the ← → keys and drag directions all mirror. 'auto' follows the container's CSS direction; the default is left-to-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">
<select aria-label="방향" id="dir">
<option value="rtl" selected>오른쪽에서 왼쪽</option>
<option value="ltr">왼쪽에서 오른쪽</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('dir').addEventListener('change', (event) => actions.dir(api, event.target.value));const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6],
city: cities[(i * 5) % 6],
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl'은 그리드를 오른쪽에서 왼쪽으로 보여요. 컬럼은 오른쪽부터 놓이고, 가로 스크롤·고정 컬럼·←→ 키가 모두 뒤집혀요.
// 'auto'는 그리드를 담은 요소의 CSS direction을 따라요. 기본(생략)은 왼쪽에서 오른쪽이에요.
export const options = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api, value) => api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};<!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">
<select aria-label="방향" id="dir">
<option value="rtl" selected>오른쪽에서 왼쪽</option>
<option value="ltr">왼쪽에서 오른쪽</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6],
city: cities[(i * 5) % 6],
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl'은 그리드를 오른쪽에서 왼쪽으로 보여요. 컬럼은 오른쪽부터 놓이고, 가로 스크롤·고정 컬럼·←→ 키가 모두 뒤집혀요.
// 'auto'는 그리드를 담은 요소의 CSS direction을 따라요. 기본(생략)은 왼쪽에서 오른쪽이에요.
const options = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
const actions = {
dir: (api, value) => api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};
options.ariaLabel = "오른쪽에서 왼쪽으로 보기(RTL)";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('dir').addEventListener('change', (event) => actions.dir(api, event.target.value));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<select
aria-label="방향"
disabled={!api}
onChange={(event) => api && actions.dir(api, event.target.value)}
>
<option value="rtl">오른쪽에서 왼쪽</option>
<option value="ltr">왼쪽에서 오른쪽</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
city: string;
qty: number;
total: number;
}
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6] as string,
city: cities[(i * 5) % 6] as string,
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl'은 그리드를 오른쪽에서 왼쪽으로 보여요. 컬럼은 오른쪽부터 놓이고, 가로 스크롤·고정 컬럼·←→ 키가 모두 뒤집혀요.
// 'auto'는 그리드를 담은 요소의 CSS direction을 따라요. 기본(생략)은 왼쪽에서 오른쪽이에요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api: GridApi<Row>, value?: string) =>
api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<select
aria-label="방향"
:disabled="!api"
@change="api && actions.dir(api, ($event.target as HTMLSelectElement).value)"
>
<option value="rtl" selected>오른쪽에서 왼쪽</option>
<option value="ltr">왼쪽에서 오른쪽</option>
</select>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
city: string;
qty: number;
total: number;
}
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6] as string,
city: cities[(i * 5) % 6] as string,
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl'은 그리드를 오른쪽에서 왼쪽으로 보여요. 컬럼은 오른쪽부터 놓이고, 가로 스크롤·고정 컬럼·←→ 키가 모두 뒤집혀요.
// 'auto'는 그리드를 담은 요소의 CSS direction을 따라요. 기본(생략)은 왼쪽에서 오른쪽이에요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api: GridApi<Row>, value?: string) =>
api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="방향"
[disabled]="!api"
(change)="api && actions.dir(api, $any($event.target).value)"
>
<option value="rtl" selected>오른쪽에서 왼쪽</option>
<option value="ltr">왼쪽에서 오른쪽</option>
</select>
</div>
<mx-grid style="height: 340px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
name: string;
city: string;
qty: number;
total: number;
}
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6] as string,
city: cities[(i * 5) % 6] as string,
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl'은 그리드를 오른쪽에서 왼쪽으로 보여요. 컬럼은 오른쪽부터 놓이고, 가로 스크롤·고정 컬럼·←→ 키가 모두 뒤집혀요.
// 'auto'는 그리드를 담은 요소의 CSS direction을 따라요. 기본(생략)은 왼쪽에서 오른쪽이에요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api: GridApi<Row>, value?: string) =>
api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<select aria-label="Direction" id="dir">
<option value="rtl" selected>Right to left</option>
<option value="ltr">Left to right</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('dir').addEventListener('change', (event) => actions.dir(api, event.target.value));const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6],
city: cities[(i * 5) % 6],
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl' shows the grid right to left. Columns start from the right, and horizontal scroll, pinned columns and the arrow keys are all mirrored.
// 'auto' follows the CSS direction of the element holding the grid. The default (omitted) is left to right.
export const options = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api, value) => api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Right-to-left layout (RTL)</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Direction" id="dir">
<option value="rtl" selected>Right to left</option>
<option value="ltr">Left to right</option>
</select>
</div>
<div id="grid" style="height: 340px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6],
city: cities[(i * 5) % 6],
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl' shows the grid right to left. Columns start from the right, and horizontal scroll, pinned columns and the arrow keys are all mirrored.
// 'auto' follows the CSS direction of the element holding the grid. The default (omitted) is left to right.
const options = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
const actions = {
dir: (api, value) => api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};
options.ariaLabel = "Right-to-left layout (RTL)";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('dir').addEventListener('change', (event) => actions.dir(api, event.target.value));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<select
aria-label="Direction"
disabled={!api}
onChange={(event) => api && actions.dir(api, event.target.value)}
>
<option value="rtl">Right to left</option>
<option value="ltr">Left to right</option>
</select>
</div>
<Grid style={{ height: 340 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
city: string;
qty: number;
total: number;
}
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6] as string,
city: cities[(i * 5) % 6] as string,
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl' shows the grid right to left. Columns start from the right, and horizontal scroll, pinned columns and the arrow keys are all mirrored.
// 'auto' follows the CSS direction of the element holding the grid. The default (omitted) is left to right.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api: GridApi<Row>, value?: string) =>
api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<select
aria-label="Direction"
:disabled="!api"
@change="api && actions.dir(api, ($event.target as HTMLSelectElement).value)"
>
<option value="rtl" selected>Right to left</option>
<option value="ltr">Left to right</option>
</select>
</div>
<Grid style="height: 340px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
city: string;
qty: number;
total: number;
}
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6] as string,
city: cities[(i * 5) % 6] as string,
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl' shows the grid right to left. Columns start from the right, and horizontal scroll, pinned columns and the arrow keys are all mirrored.
// 'auto' follows the CSS direction of the element holding the grid. The default (omitted) is left to right.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api: GridApi<Row>, value?: string) =>
api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="Direction"
[disabled]="!api"
(change)="api && actions.dir(api, $any($event.target).value)"
>
<option value="rtl" selected>Right to left</option>
<option value="ltr">Left to right</option>
</select>
</div>
<mx-grid style="height: 340px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
name: string;
city: string;
qty: number;
total: number;
}
const names = ['أحمد', 'ليلى', 'يوسف', 'مريم', 'عمر', 'سارة'];
const cities = ['القاهرة', 'عمّان', 'بيروت', 'الرباط', 'تونس', 'دبي'];
const rows: Row[] = Array.from({ length: 14 }, (_, i) => ({
id: i + 1,
name: names[i % 6] as string,
city: cities[(i * 5) % 6] as string,
qty: 3 + ((i * 7) % 20),
total: 1200 + ((i * 937) % 9000),
}));
// direction: 'rtl' shows the grid right to left. Columns start from the right, and horizontal scroll, pinned columns and the arrow keys are all mirrored.
// 'auto' follows the CSS direction of the element holding the grid. The default (omitted) is left to right.
export const options: GridOptions<Row> = {
columns: [
{ id: 'id', title: '#', width: 60, pinned: 'start' },
{ id: 'name', title: 'الاسم', width: 140, editable: true },
{ id: 'city', title: 'المدينة', width: 140 },
{ id: 'qty', title: 'الكمية', kind: 'number', width: 100 },
{ id: 'total', title: 'المجموع', kind: 'number', width: 120, pinned: 'end' },
],
direction: 'rtl',
cellSelection: 'multiple',
rows,
rowKey: 'id',
};
export const actions = {
dir: (api: GridApi<Row>, value?: string) =>
api.setOptions({ direction: value === 'ltr' ? 'ltr' : 'rtl' }),
};