Skip to content

Features

The DataTable component provides flexible configuration options through various props. Below is a detailed explanation of its features.

Example Usage

vue

<template>
  <DataTable
    uniqueId="example-table"
    :columns="columns"
    :isServerMode="true"
    endpoint="https://api.example.com/data"
    :pagination="pagination"
    :filter="filter"
    :representation="representation"
  />
</template>

<script setup>
  import DataTable from "ares-datatable"

  const columns = [
    {field: 'id', title: 'ID', sort: true},
    {field: 'name', title: 'Name', filter: true},
    {field: 'price', title: 'Price', type: 'number', sort: true}
  ];

  const pagination = {
    page: 1,
    pageSize: 20,
    usePagination: true,
    showNumbersCount: 5
  };

  const filter = {
    search: '',
    useSorting: true,
    sortColumn: 'name',
    sortDirection: 'asc'
  };

  const representation = {
    height: '500px',
    hasCheckbox: true
  };
</script>

Basic Props

PropTypeRequiredDescription
uniqueIdstringA required unique identifier to prevent conflicts between multiple tables.
columnsColumn[]Defines the structure and representation of table columns. See Column Configuration.
isServerModebooleanDetermines whether data should be fetched from an API (true) or handled locally (false).
rowsObject[]Used only when isServerMode = false to provide local data.
endpointstringUsed only when isServerMode = true, specifies the API endpoint to fetch data.

Column Configuration

Each column in the columns array should be an object of type Column:

PropTypeDefaultDescription
fieldstringThe field in the data object that should be displayed.
titlestringThe title/header of the column.
typeColumnTypeDefines the type of column (e.g., text, number, date).
filter`ColumnFilterboolean`false
htmlbooleanfalseAllows rendering HTML content inside the column.
sortbooleanfalseEnables sorting for this column.
classNamestringAdds a custom class to the column.
widthstringSets a fixed width for the column.

Pagination Settings

The pagination prop allows you to control how table pagination works.

PropTypeDefaultDescription
pagenumber1The initial page when the table is loaded.
pageSizenumber20Number of items per page.
usePaginationbooleanfalseEnables or disables pagination.
showNumbersCountnumber4Number of page numbers displayed between navigation arrows.
noDataContentstring'No data available'Message displayed when there is no data due to filtering.

For more details, refer to the Pagination Guide.

Filtering and Sorting Settings

The filter prop enables advanced data manipulation.

PropTypeDefaultDescription
search`stringnull`null
useSortingbooleanfalseEnables sorting functionality.
sortColumn`stringnull`null
sortDirectionSortDirection'asc'Sorting direction (asc or desc).
useFilteringbooleanfalseEnables filtering functionality.

Representation Settings

The representation prop customizes the table’s appearance and behavior.

PropTypeDefaultDescription
skinstringDefines a custom theme or styling preset.
rowClass`stringfunction`
cellClass`stringfunction`
heightstringDefines the height of the table.
loadingbooleanfalseDisplays a loading state when fetching data.
hasAutoListingbooleanfalseAutomatically loads more data when scrolling.
hasCheckboxbooleanfalseEnables checkboxes for row selection.
cloneHeaderInFooterbooleanfalseClones the table header in the footer for better visibility.

This guide provides an overview of the main features available in the DataTable component. For further details, check the individual guides on Pagination, Filtering, and Server Mode.