Skip to content
ParaLogicTechPublic
forked from frappe/datatable

About

A simple, modern and interactive datatable library for the web

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

datatable-logo

Frappe DataTable

A modern datatable library for the web

Test and Release npm version

ParaLogic's fork of frappe/datatable, published as @paralogic/frappe-datatable. See Fork additions.

demo.mp4

Frappe Datatable

Frappe DataTable is a simple, modern and interactive datatable library for displaying tabular data. Originally built for ERPNext, it can be used to render large amount of rows without sacrificing performance and has the basic data grid features like inline editing and keyboard navigation. It does not require jQuery, unlike most data grids out there.

Motivation

I was trying to remove all legacy UI components from the frappe codebase. We were using SlickGrid for rendering tables. It was unmaintained and UI was dated. Other datatable solutions either didn't have the features we needed or were closed source. So we built our own.

Key Features

  • Cell: Enable editing within individual cells and features like custom formatters, inline editing, and mouse selection. Users can easily copy cell content, navigate through cells using the keyboard, and take advantage of a custom cell editor for advanced functionality.
  • Column: Columns are highly flexible, allowing users to reorder, resize, and sort them with ease. Additional features include hiding/removing columns and adding custom actions.
    • Freeze a column from its header menu so it stays in view while scrolling sideways, or set sticky: true on the column.
    • Column widths fit the widest value in all rows, and widths a user resized are kept when the data refreshes.
    • Set sortValue on a column to sort on a value other than the cell content.
  • Row: Rows support advanced interactions, including row selection, tree-structured organization, and inline filters for precise control. They handle large datasets efficiently with dynamic row heights.
    • In tree view, sorting keeps child rows under their parent.
    • Total rows (is_total_row) and blank rows keep their place when the table is sorted.
  • Options: serialNoColumnLabel sets the header of the serial number column. saveSorting remembers the last sort in local storage, under sortingKey when it is set.
  • Fuzzy filter: set filterMode: 'fuzzy' on the table, or on a single column, so an inline filter matches letters typed in order with gaps allowed (jdmr finds "Jordan Moreau"). Each word matches on its own, in any order, and a word of four or more letters may have one typo (saftware finds "Software"). Number filters such as >100 work as before.

Fork additions

  • Grouped data: pass { _isGroup: true, rows: [...] } objects in data. They can be nested.
    • With totals: {...}, the group renders as a tree: a group-total row with its rows indented under it.
    • Without totals, the group renders as a flat list, with a blank row between groups.
  • getData(rowIndex) returns the original row object, also for rows that came from a group.
  • _excludeFromTotal: true on a row object leaves it out of the total row and of hooks.columnTotal. Group-total rows set it automatically.
  • Keyboard navigation, scrolling and focus fixes, plus extra null checks for custom editors and selection.

Usage

yarn add @paralogic/frappe-datatable
# or
npm install @paralogic/frappe-datatable

Note: sortablejs is required to be installed as well.

import DataTable from '@paralogic/frappe-datatable';

const datatable = new DataTable('#datatable', {
  columns: [ 'First Name', 'Last Name', 'Position' ],
  data: [
    [ 'Don', 'Joe', 'Designer' ],
    [ 'Mary', 'Jane', 'Software Developer' ]
  ]
});

Browser Support

DataTable works in current versions of Chrome, Edge, Firefox and Safari. Internet Explorer is not supported: the build ships ES2015 classes and arrow functions, and the styles use CSS custom properties.

Development Setup

  • yarn start - Start dev server
  • Open index.html located in the root folder, and start development.
  • Run yarn lint before committing changes
  • yarn test - Run the Playwright tests against index.html (run yarn build first, and yarn playwright install chromium once)
  • This project uses commitizen for conventional commit messages, use yarn commit command instead of git commit
  • Releases are manual: run the Test and Release workflow on master. Leave version blank to let semantic-release compute it from the commit messages (fix: → patch, feat: → minor), or give an exact version. dry_run is on by default. See CLAUDE.md for details.

Links



About

A simple, modern and interactive datatable library for the web

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages