Lattice Grid Buy a licence

demo D219

Locales, and it mirrors

The same grid in English, Japanese and Arabic, which sets the grid right to left

locale · direction: 'rtl'

Building…
Loading a live grid…

The configuration

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.min.css">
<style>
  #buttons { display: flex; gap: 8px; margin-bottom: 12px; }
  #grid > div { height: 460px; }
</style>
<div id="app"></div>

<script type="module">
  import * as Vue from 'https://esm.sh/vue@3';
  import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.esm.min.js';
  import createLatticeGrid from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/modules/vue.esm.min.js';

  const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });

  Vue.createApp({
    components: { LatticeGrid },
    data() {
      return {
        active: 'English',
        // The same grid and the same rows in three locales. Only the chrome and the
        // formatting change: numbers, currency and dates read the grid's locale, and
        // Arabic sets direction: 'rtl', which mirrors the whole grid, pin and all.
        locales: {
          English:  { locale: 'en-GB', direction: 'ltr', currency: 'GBP', titles: ['Product', 'Price', 'Updated', 'Share'] },
          日本語:    { locale: 'ja-JP', direction: 'ltr', currency: 'JPY', titles: ['製品', '価格', '更新日', 'シェア'] },
          العربية:  { locale: 'ar-EG', direction: 'rtl', currency: 'EGP', titles: ['المنتج', 'السعر', 'تاريخ التحديث', 'الحصة'] },
        },
      };
    },
    computed: {
      // locale and direction are read when the grid is built, so keying the
      // component on the active locale rebuilds it on every switch.
      config() {
        const L = this.locales[this.active];
        return {
          rowKey: 'id',
          locale: L.locale,
          direction: L.direction,
          columns: [
            { field: 'product', title: L.titles[0], layout: { pin: 'start', width: 180 } },
            { field: 'price', title: L.titles[1], type: 'number',
              format: { style: 'currency', currency: L.currency }, total: 'sum' },
            { field: 'updated', title: L.titles[2], type: 'date' },
            { field: 'share', title: L.titles[3], type: 'number', format: { style: 'percent' } },
          ],
          rows,  // e.g. [{ id: 1, product: 'Desk lamp', price: 42.5, updated: '2026-08-01', share: 0.18 }, ...]
        };
      },
    },
    template: `
      <div>
        <div id="buttons">
          <button v-for="name in Object.keys(locales)" :key="name" @click="active = name">{{ name }}</button>
        </div>
        <div id="grid"><lattice-grid :key="active" v-bind="config" /></div>
      </div>
    `,
  }).mount('#app');
</script>