본문으로 건너뛰기Skip to content
예제 첫화면Examples home

오른쪽에서 왼쪽으로 보기(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.

입문Beginner
직접 써 보기Live preview오른쪽에서 왼쪽으로 보기(RTL)Right-to-left layout (RTL)

코드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)

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<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>
main.js
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));
example.js
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' }),
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<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>
main.js
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));
example.js
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' }),
};