Skip to main content

Documentation: MejikDatatable Component (English)

1. Overview

MejikDatatable is a comprehensive, server-side data table component. It acts as a “controller” or “wrapper” that provides a rich user interface for pagination, searching, and row selection, while delegating the actual data fetching and table rendering to a parent component and a child TreeDatatable component, respectively. Its primary design principle is that it does not manage data itself. Instead, it captures user interactions (like changing a page, sorting, or searching) and emits events with structured parameters. The parent component is responsible for listening to these events, making an API call with the parameters, and then passing the new data back into the datatable via props.

2. Features

  • Server-Side Driven: Built from the ground up to work with server-side data, ensuring it can handle large datasets efficiently.
  • Integrated UI: Provides out-of-the-box UI for global search, pagination (top and bottom), and per-page selection.
  • Row Selection: Supports single and multi-row selection with checkboxes and a “selected rows” summary bar.
  • Loading State: Displays a clean loading spinner overlay while the parent is fetching data.
  • Slot Passthrough: All scoped slots are passed directly to the underlying TreeDatatable, allowing for complete customization of columns, cells, and rows.
  • Event-Based Communication: Uses a clear, event-driven model for interacting with the parent component.

3. Props

Core Data & Display Props

Feature Configuration Props

4. Emitted Events

This is the primary way the component communicates with its parent.

5. Scoped Slots

MejikDatatable passes all scoped slots it receives directly to the TreeDatatable component inside it. This allows for powerful customization. Common Slots:
  • #table-row="{ row, formattedRow, index }": Customize an entire table row.
  • #table-cell-[field]="{ row, formattedRow, column, ... }": Customize a specific cell based on the column’s field name.

6. Usage Example

Dokumentasi: Komponen MejikDatatable (Bahasa Indonesia)

1. Gambaran Umum

MejikDatatable adalah komponen tabel data sisi server (server-side) yang komprehensif. Komponen ini bertindak sebagai “pengontrol” atau “pembungkus” (wrapper) yang menyediakan antarmuka pengguna yang kaya untuk paginasi, pencarian, dan pemilihan baris, sambil mendelegasikan pengambilan data dan rendering tabel ke komponen induk dan komponen anak TreeDatatable. Prinsip desain utamanya adalah komponen ini tidak mengelola data itu sendiri. Sebaliknya, ia menangkap interaksi pengguna (seperti mengganti halaman, mengurutkan, atau mencari) dan memancarkan event dengan parameter terstruktur. Komponen induk bertanggung jawab untuk mendengarkan event ini, melakukan panggilan API dengan parameter tersebut, dan kemudian mengoper data baru kembali ke datatable melalui props.

2. Fitur

  • Digerakkan oleh Server-Side: Dibangun dari awal untuk bekerja dengan data sisi server, memastikannya dapat menangani dataset besar secara efisien.
  • UI Terintegrasi: Menyediakan UI siap pakai untuk pencarian global, paginasi (atas dan bawah), dan pemilihan item per halaman.
  • Pemilihan Baris: Mendukung pemilihan baris tunggal dan ganda dengan checkbox dan ringkasan “baris terpilih”.
  • Status Loading: Menampilkan overlay spinner saat komponen induk sedang mengambil data.
  • Penerusan Slot (Slot Passthrough): Semua scoped slot diteruskan langsung ke TreeDatatable di dalamnya, memungkinkan kustomisasi penuh pada kolom, sel, dan baris.
  • Komunikasi Berbasis Event: Menggunakan model berbasis event yang jelas untuk berinteraksi dengan komponen induk.

3. Props

Props Inti Data & Tampilan

Props Konfigurasi Fitur

4. Event yang Di-emit

Ini adalah cara utama komponen berkomunikasi dengan induknya.

5. Scoped Slots

MejikDatatable meneruskan semua scoped slot yang diterimanya langsung ke komponen TreeDatatable di dalamnya. Ini memungkinkan kustomisasi yang sangat kuat. Slot Umum:
  • #table-row="{ row, formattedRow, index }": Kustomisasi seluruh baris tabel.
  • #table-cell-[field]="{ row, formattedRow, column, ... }": Kustomisasi sel spesifik berdasarkan nama field dari kolom.

6. Contoh Penggunaan

(Contoh kode sama seperti versi Bahasa Inggris, dengan komentar yang dapat diterjemahkan jika perlu. Kode itu sendiri bersifat universal.)