Documentation

Complete guide to using SkarGrid in your projects

Installation

Install SkarGrid via CDN or npm.

CDN

<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/skargrid@1.3.0/dist/skargrid.min.css">

<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/skargrid@1.3.0/dist/skargrid.min.js"></script>

npm

npm install skargrid

Basic Usage

Create a simple table with minimal configuration.

HTML

<div id="my-table"></div>

JavaScript

const data = [
  { name: 'John Doe', email: 'john@example.com' },
  { name: 'Jane Smith', email: 'jane@example.com' }
];

const columns = [
  { field: 'name', title: 'Name' },
  { field: 'email', title: 'Email' }
];

new Skargrid('my-table', {
  data: data,
  columns: columns
});

Configuration Options

Only the options below are guaranteed to be supported in the current version of SkarGrid.

Option Type Default Description
dataArray[]Array of data objects (rows)
columnsArray[]Array of column definitions (see below)
paginationBooleanfalseEnable pagination
pageSizeNumber10Items per page
pageSizeOptionsArray[10,25,50,100]Page size dropdown options
sortableBooleanfalseEnable sorting for all columns
searchableBooleanfalseEnable global search box
columnFiltersBooleanfalseEnable column filter dropdowns
selectableBooleanfalseEnable row selection (checkboxes)
columnConfigBooleanfalseEnable column config (show/hide, reorder)
persistColumnConfigBooleanfalseSave column config in localStorage
storageKeyString'skargrid-config-{id}'Key for localStorage persistence
themeString'light'Table theme: 'light' or 'dark'
classNameString'skargrid'Custom table CSS class
exportCSVBooleanfalseEnable CSV export button
exportXLSXBooleanfalseEnable XLSX export button
exportFilenameString'skargrid-export'Base filename for exports
exportSelectedOnlyBooleanfalseExport only selected rows
noDataTextString'No data available'Text to show when table is empty
rowIdStringField to use as unique row id
rowClassFunctionFunction to set custom class per row
onRowClickFunctionCallback for row click: (row, index) => {}
onSelectionChangeFunctionCallback for selection change
onFilterChangeFunctionCallback for filter change
onPageChangeFunctionCallback for page change
onSortChangeFunctionCallback for sort change
loadingBooleanfalseShow loading shimmer overlay
persistSelectionBooleanfalseKeep selection after data reload
showFooterBooleanfalseShow table footer (if supported)
autoHeightBooleanfalseTable grows to fit content (no scroll)
fixedHeaderBooleanfalseTable header stays fixed on scroll
labelsObject{...}Custom labels for internationalization
Column Definition Options:
Option Type Default Description
fieldStringField name in data object (required)
titleStringColumn header label
widthStringColumn width (e.g. '120px', '10%')
visibleBooleantrueShow/hide column
sortableBooleanfalseEnable sorting for this column
sortTypeString'string'Sort type: 'string', 'number', 'date'
filterableBooleanfalseShow filter for this column
filterTypeString'text'Filter type: 'text', 'number', 'date', 'select'
renderFunctionCustom cell render: (value, row) => html
formatterFunction(legacy) Custom cell formatter

Internationalization (i18n)

SkarGrid supports full internationalization through the labels option. You can customize all user-facing text to match your application's language.

Available Labels

The following labels can be customized:

Label Key Default (English) Description
searchPlaceholder'Search all columns...'Global search input placeholder
clearFilters'Clear Filters'Button to clear all filters
exportCSV'Export CSV'CSV export button text
exportXLSX'Export XLSX'XLSX export button text
filterTitle'Filter: {title}'Filter dropdown title
selectAll'Select All'Select all rows checkbox label
filterSearchPlaceholder'Search...'Filter dropdown search placeholder
filterInputPlaceholder'Type to filter...'Filter input placeholder
clear'Clear'Clear button in filter dropdown
apply'Apply'Apply button in filter dropdown
showing'Showing {start} to {end} of {total} entries'Pagination info text
filteredOfTotal'filtered from {total} total'Filtered results info
itemsPerPage'Items per page:'Page size selector label
noRowsSelected'No rows selected to export.'Export warning message
columnConfigTitle'Configure Columns'Column config modal title
columnConfigDescription'Check to display, drag or use arrows to reorder'Column config description
restore'Restore'Restore defaults button
cancel'Cancel'Cancel button
noData'No data available'Empty table message
loading'Loading...'Loading state message

Example: Portuguese Labels

const table = new Skargrid('myTable', {
  data: myData,
  columns: myColumns,
  labels: {
    searchPlaceholder: 'Buscar em todas as colunas...',
    clearFilters: 'Limpar Filtros',
    exportCSV: 'Exportar CSV',
    exportXLSX: 'Exportar XLSX',
    filterTitle: 'Filtrar: {title}',
    selectAll: 'Selecionar Todos',
    clear: 'Limpar',
    apply: 'Aplicar',
    showing: 'Mostrando {start} até {end} de {total} registros',
    itemsPerPage: 'Itens por página:'
  }
});
Tip: You can also internationalize column titles by setting the title property in your column definitions.

API Reference

Constructor

new Skargrid(selector, options)

Parameters

  • selector: CSS selector or DOM element
  • options: Configuration object