Top Related Projects
Create beautiful JavaScript charts with one line of Ruby
React components for efficiently rendering large lists and tabular data
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡
A lightning fast JavaScript grid/spreadsheet
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Quick Overview
Simple-DataTables is a lightweight, extendable JavaScript library for creating interactive HTML tables. It provides features like sorting, searching, and pagination without external dependencies, making it easy to integrate into various web projects.
Pros
- Lightweight and dependency-free
- Easy to set up and use
- Customizable with various configuration options
- Supports modern browsers and IE11+
Cons
- Limited advanced features compared to more complex libraries
- Documentation could be more comprehensive
- Fewer pre-built themes and styling options
- May require custom development for complex use cases
Code Examples
- Basic table initialization:
const dataTable = new simpleDatatables.DataTable("#myTable", {
searchable: true,
fixedHeight: true,
perPage: 10
});
This code initializes a new DataTable with search functionality, fixed height, and 10 rows per page.
- Custom sorting:
const dataTable = new simpleDatatables.DataTable("#myTable", {
columns: [
{ select: 2, sort: "asc" },
{ select: 3, sortable: false }
]
});
This example sets the third column to sort ascending by default and disables sorting for the fourth column.
- Adding custom buttons:
const dataTable = new simpleDatatables.DataTable("#myTable");
dataTable.on("datatable.init", function() {
const button = document.createElement("button");
button.textContent = "Export";
button.addEventListener("click", () => {
dataTable.export({
type: "csv",
download: true,
filename: "table-export"
});
});
dataTable.wrapper.querySelector(".dataTable-top").appendChild(button);
});
This code adds a custom "Export" button to the table that exports the data as a CSV file when clicked.
Getting Started
- Include the Simple-DataTables CSS and JS files in your HTML:
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" type="text/javascript"></script>
- Create an HTML table with a unique ID:
<table id="myTable">
<!-- Table content -->
</table>
- Initialize the DataTable in your JavaScript:
const dataTable = new simpleDatatables.DataTable("#myTable");
This will create a basic interactive table with default options. You can customize it further by passing configuration options to the constructor.
Competitor Comparisons
Create beautiful JavaScript charts with one line of Ruby
Pros of Chartkick
- Supports a wide variety of chart types (line, bar, pie, etc.)
- Easy integration with multiple backend frameworks (Rails, Django, etc.)
- Offers both JavaScript and server-side rendering options
Cons of Chartkick
- Primarily focused on charts, less suitable for complex data tables
- May require additional setup for advanced customization
- Larger file size due to comprehensive charting capabilities
Code Comparison
Chartkick:
new Chartkick.LineChart("chart-1", {"2021-01-01": 11, "2021-01-02": 6})
Simple-datatables:
let dataTable = new simpleDatatables.DataTable("#myTable", {
searchable: false,
fixedHeight: true
})
Key Differences
- Simple-datatables is specifically designed for creating interactive data tables, while Chartkick focuses on chart generation
- Chartkick offers more built-in chart types and integrations with various backend frameworks
- Simple-datatables provides more advanced table features like sorting, searching, and pagination out of the box
- Chartkick is better suited for visualizing data trends, while Simple-datatables excels at displaying and manipulating tabular data
Both libraries serve different primary purposes, with some overlap in data presentation capabilities. The choice between them depends on whether the project requires more emphasis on charting or tabular data display and manipulation.
React components for efficiently rendering large lists and tabular data
Pros of react-virtualized
- Highly performant for large datasets, efficiently rendering only visible rows
- Offers a wide range of components beyond tables (e.g., lists, grids)
- Extensive customization options and flexibility
Cons of react-virtualized
- Steeper learning curve due to its complexity and numerous features
- Requires more setup and configuration compared to simpler alternatives
- May be overkill for smaller datasets or simpler use cases
Code Comparison
react-virtualized:
import { Table, Column } from 'react-virtualized';
<Table
width={300}
height={300}
headerHeight={20}
rowHeight={30}
rowCount={list.length}
rowGetter={({ index }) => list[index]}
>
<Column label="Name" dataKey="name" width={100} />
<Column label="Age" dataKey="age" width={100} />
</Table>
simple-datatables:
import { DataTable } from "simple-datatables"
const dataTable = new DataTable("#myTable", {
data: {
headings: ["Name", "Age"],
data: [
["John", 30],
["Jane", 25]
]
}
});
react-virtualized offers more granular control and is designed for handling large datasets efficiently, while simple-datatables provides a simpler API for basic table functionality.
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
Pros of ag-grid
- More feature-rich with advanced functionalities like grouping, filtering, and cell editing
- Better performance for handling large datasets
- Extensive documentation and community support
Cons of ag-grid
- Steeper learning curve due to its complexity
- Larger file size, which may impact load times
- Commercial license required for some advanced features
Code Comparison
simple-datatables:
const dataTable = new simpleDatatables.DataTable("#myTable", {
searchable: true,
fixedHeight: true,
columns: [
{ select: 2, sort: "desc" }
]
});
ag-grid:
const gridOptions = {
columnDefs: [
{ field: 'name' },
{ field: 'age', sort: 'desc' }
],
rowData: rowData
};
new agGrid.Grid(document.querySelector('#myGrid'), gridOptions);
Summary
ag-grid offers more advanced features and better performance for large datasets, but comes with a steeper learning curve and potential licensing costs. simple-datatables is easier to use and lightweight, making it suitable for simpler projects. The code comparison shows that ag-grid requires more configuration but offers more granular control over grid behavior.
JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡
Pros of Handsontable
- More feature-rich with advanced functionalities like data validation, sorting, and filtering
- Supports various data types and cell types (e.g., dropdown, date picker)
- Extensive documentation and community support
Cons of Handsontable
- Larger file size and potentially higher performance overhead
- Steeper learning curve due to more complex API
- Commercial license required for some features
Code Comparison
Simple-datatables:
let dataTable = new simpleDatatables.DataTable("#myTable", {
searchable: true,
fixedHeight: true,
columns: [
{ select: 2, sort: "desc" }
]
});
Handsontable:
const hot = new Handsontable(document.getElementById('myTable'), {
data: myData,
rowHeaders: true,
colHeaders: true,
filters: true,
dropdownMenu: true
});
Summary
Simple-datatables is lightweight and easy to use, making it suitable for simpler table needs. Handsontable offers more advanced features and customization options but comes with a larger footprint and potential licensing costs. The choice between the two depends on the specific requirements of your project, such as the complexity of data handling, performance considerations, and budget constraints.
A lightning fast JavaScript grid/spreadsheet
Pros of SlickGrid
- More feature-rich with advanced functionalities like frozen columns, grouping, and custom editors
- Better performance for handling large datasets (100,000+ rows)
- Extensive documentation and a larger community for support
Cons of SlickGrid
- Steeper learning curve due to its complexity
- Heavier footprint, which may impact page load times
- Less modern API and syntax compared to newer libraries
Code Comparison
SlickGrid:
var grid = new Slick.Grid("#myGrid", data, columns, options);
grid.onCellChange.subscribe(function (e, args) {
// Handle cell change
});
simple-datatables:
const dataTable = new simpleDatatables.DataTable("#myTable", {
data: {
headings: ["Name", "Age", "City"],
data: [["John", 30, "New York"], ["Jane", 25, "London"]]
}
});
Summary
SlickGrid offers more advanced features and better performance for large datasets, but comes with a steeper learning curve and a heavier footprint. simple-datatables provides a more modern and straightforward API, making it easier to implement for simpler use cases. The choice between the two depends on the specific requirements of your project, such as dataset size, required features, and development complexity preferences.
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Pros of TanStack Table
- Highly flexible and customizable, with support for advanced features like sorting, filtering, and pagination
- Framework-agnostic, compatible with React, Vue, Solid, and vanilla JS
- Strong TypeScript support and type safety
Cons of TanStack Table
- Steeper learning curve due to its extensive API and configuration options
- Requires more setup and boilerplate code for basic use cases
- Larger bundle size compared to Simple DataTables
Code Comparison
Simple DataTables:
const dataTable = new DataTable("#myTable", {
searchable: true,
fixedHeight: true,
perPage: 10
});
TanStack Table:
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getSortedRowModel: getSortedRowModel(),
});
Summary
Simple DataTables is a lightweight, easy-to-use library for creating basic data tables with minimal configuration. It's ideal for simple use cases and quick implementations. TanStack Table, on the other hand, offers a more powerful and flexible solution for complex data table requirements, with support for multiple frameworks and advanced features. However, it comes with a steeper learning curve and requires more setup.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
simple-datatables
A lightweight, extendable, JavaScript HTML table library written in TypeScript and transpilled to Vanilla JavaScript. Similar to jQuery DataTables for use in modern browsers, but without the jQuery dependency.
Examples / Demos
See the demos here and the documentation here.
Upgrading
For upgrading from one major version to another, check the upgrade guide: https://fiduswriter.github.io/simple-datatables/documentation/Upgrading
Note: The upgrade from version 5 version 6 is the most complicated upgrade so far. Please read through the instructions before filing complaints. If you run simple-datatables from a CDN, make sure that you have fixed it to a specific major or minor version so that you do not accidentally upload to a new version that requires you to do lots of manual adjustments.
CDN
To use the CDN version of simple-datatables use either https://cdn.jsdelivr.net/npm/simple-datatables@latest or https://unpkg.com/simple-datatables. You also need to add the CSS styling, so the elements you'll add to html head element can for example be these:
Note: For production websites, specify a specific major version. For example https://cdn.jsdelivr.net/npm/simple-datatables@6 for the latest version in the 6.x.x series or https://cdn.jsdelivr.net/npm/simple-datatables@6.0 for the latest version in the 6.0.x series.
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" type="text/javascript"></script>
License
LGPL
Features
- Sortable/filterable columns
- Pagination
- Searchable
- Customisable layout
- Customisable labels
- Customise column rendering
- Export to common formats like
csv
,txt
,json
, andsql
- Import
csv
andjson
data - Control column visibility
- Reorder or swap columns
- dayjs integration for sorting columns with datetime strings
- Using diffDOM for faster DOM updates.
simple-datatables Documentation
History
This project started as a fork of Vanilla-DataTables, but it has since been converted to TypeScript.
If you want a version that works in very old browsers (IE, etc.), then head over to https://github.com/fiduswriter/simple-datatables-classic .
Install
npm
npm install simple-datatables --save
Yarn
yarn add simple-datatables
Quick Start
Then just initialise the plugin by import DataTable and either passing a reference to the table or a CSS3 selector string as the first parameter:
import {DataTable} from "simple-datatables"
const myTable = document.querySelector("#myTable");
const dataTable = new DataTable(myTable);
// or
const dataTable = new DataTable("#myTable");
You can also pass the options object as the second parameter:
import {DataTable} from "simple-datatables"
const dataTable = new DataTable("#myTable", {
searchable: false,
fixedHeight: true,
...
})
If using the CDN:
const dataTable = new simpleDatatables.DataTable("#myTable", {
searchable: false,
fixedHeight: true,
...
})
How to contribute?
- Fork the repository
- Create a sub-branch
- Clone the sub-branch to your local system
- Install NodeJS
- Open the project in a code editor (for example Visual Studio Code or Pulsar Edit)
- Open the Terminal
- Run
npm install
in the Terminal - Start making changes and contributing to the project ð
- You can run
npm run test_server
to test your code. This runs on port 3000 (http://localhost:3000/) - You can also run
npm run build
in the Terminal to build the final files - Once finished, then commit/push your code and create a Pull Request on GitHub for the changes
Top Related Projects
Create beautiful JavaScript charts with one line of Ruby
React components for efficiently rendering large lists and tabular data
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡
A lightning fast JavaScript grid/spreadsheet
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot