list.js
The perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML.
Top Related Projects
An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
Github fork of Christian Bach's tablesorter plugin + awesomeness ~
Tables plug-in for jQuery
DataTables but in TypeScript transpiled to Vanilla JS
React components for efficiently rendering large lists and tabular data
Quick Overview
List.js is a lightweight JavaScript library for adding search, sort, filters, and flexibility to HTML lists, tables, or anything. It's designed to be simple to use and requires no dependencies, making it easy to integrate into various web projects.
Pros
- Lightweight and fast, with no dependencies
- Easy to implement and customize
- Works with existing HTML structures
- Supports pagination and fuzzy search
Cons
- Limited advanced features compared to larger data grid libraries
- May require additional coding for complex use cases
- Documentation could be more comprehensive
- Not actively maintained (last update was in 2018)
Code Examples
- Basic list initialization:
var options = {
valueNames: ['name', 'born']
};
var userList = new List('users', options);
This code initializes a new List.js instance for an element with the ID 'users', specifying 'name' and 'born' as sortable/searchable values.
- Adding search functionality:
var options = {
valueNames: ['name', 'born'],
searchClass: 'search'
};
var userList = new List('users', options);
This example adds a search functionality to the list, using an input field with the class 'search'.
- Adding new items dynamically:
userList.add({
name: "Gustaf Lindqvist",
born: 1983
});
This code adds a new item to the list dynamically.
- Sorting the list:
userList.sort('name', { order: "asc" });
This example sorts the list by the 'name' field in ascending order.
Getting Started
To use List.js in your project, follow these steps:
- Include the List.js library in your HTML file:
<script src="//cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script>
- Create your HTML structure:
<div id="users">
<input class="search" placeholder="Search" />
<button class="sort" data-sort="name">Sort by name</button>
<ul class="list">
<li>
<h3 class="name">Jonny Strömberg</h3>
<p class="born">1986</p>
</li>
<li>
<h3 class="name">Jonas Arnklint</h3>
<p class="born">1985</p>
</li>
</ul>
</div>
- Initialize List.js in your JavaScript:
var options = {
valueNames: ['name', 'born']
};
var userList = new List('users', options);
Now you have a searchable and sortable list using List.js!
Competitor Comparisons
An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
Pros of bootstrap-table
- More feature-rich with built-in pagination, sorting, and filtering
- Better integration with Bootstrap framework for consistent styling
- Extensive documentation and examples for various use cases
Cons of bootstrap-table
- Larger file size and potentially slower performance for simple use cases
- Steeper learning curve due to more complex API and configuration options
- Dependency on Bootstrap framework may be unnecessary for some projects
Code Comparison
list.js:
var options = {
valueNames: ['name', 'born']
};
var userList = new List('users', options);
bootstrap-table:
$('#table').bootstrapTable({
columns: [{
field: 'name',
title: 'Name'
}, {
field: 'born',
title: 'Born'
}],
data: userList
});
Summary
list.js is a lightweight, flexible solution for adding search, sort, and filter functionality to HTML lists and tables. It's ideal for simpler projects or when minimal dependencies are desired.
bootstrap-table offers a more comprehensive set of features and integrates seamlessly with Bootstrap, making it suitable for larger, more complex projects that require advanced table functionality and consistent styling within the Bootstrap ecosystem.
The choice between the two depends on project requirements, existing dependencies, and desired level of customization.
Github fork of Christian Bach's tablesorter plugin + awesomeness ~
Pros of tablesorter
- More comprehensive feature set, including advanced sorting options and widgets
- Better support for large datasets and complex table structures
- Extensive documentation and examples
Cons of tablesorter
- Steeper learning curve due to its complexity
- Larger file size and potentially higher performance overhead
- Requires jQuery as a dependency
Code Comparison
list.js:
var options = {
valueNames: ['name', 'born']
};
var userList = new List('users', options);
tablesorter:
$(function() {
$("#myTable").tablesorter({
theme: 'blue',
widgets: ['zebra', 'filter']
});
});
Summary
list.js is a lightweight and easy-to-use library for adding search, sort, and filter functionality to HTML lists and tables. It's ideal for simpler projects and has no dependencies.
tablesorter is a more powerful and feature-rich jQuery plugin for sorting and filtering tables. It offers advanced customization options and is better suited for complex table management needs in larger projects.
The choice between the two depends on the specific requirements of your project, the complexity of your data, and whether you're already using jQuery in your application.
Tables plug-in for jQuery
Pros of DataTables
- More feature-rich with built-in pagination, sorting, and filtering
- Extensive documentation and community support
- Seamless integration with server-side processing for large datasets
Cons of DataTables
- Larger file size and potentially slower performance for small datasets
- Steeper learning curve due to more complex API
- Requires jQuery, which may not be ideal for all projects
Code Comparison
List.js:
var options = {
valueNames: ['name', 'born']
};
var userList = new List('users', options);
DataTables:
$(document).ready(function() {
$('#myTable').DataTable({
columns: [
{ data: 'name' },
{ data: 'born' }
]
});
});
Summary
List.js is lightweight and easy to use, making it ideal for simple list manipulation and small datasets. It has a smaller footprint and doesn't require jQuery.
DataTables offers more advanced features out of the box, including pagination and server-side processing. It's better suited for complex table management and larger datasets but comes with a larger file size and jQuery dependency.
Choose List.js for simple, lightweight list manipulation, and DataTables for feature-rich, complex table management with larger datasets.
DataTables but in TypeScript transpiled to Vanilla JS
Pros of simple-datatables
- More feature-rich, offering advanced sorting, filtering, and pagination options
- Better support for larger datasets and server-side processing
- Includes built-in responsive design features for mobile compatibility
Cons of simple-datatables
- Larger file size and potentially higher memory usage
- Steeper learning curve due to more complex API and configuration options
- May be overkill for simple list management tasks
Code Comparison
list.js:
var options = {
valueNames: ['name', 'born']
};
var userList = new List('users', options);
simple-datatables:
const dataTable = new simpleDatatables.DataTable("#myTable", {
searchable: true,
fixedHeight: true,
columns: [
{ select: 2, sort: "desc" }
]
});
Summary
list.js is lightweight and straightforward, ideal for simple list management and client-side searching. simple-datatables offers more advanced features and better handles large datasets, but comes with increased complexity and resource usage. Choose based on your project's specific needs and performance requirements.
React components for efficiently rendering large lists and tabular data
Pros of react-virtualized
- Optimized for rendering large lists and tabular data efficiently
- Supports windowing techniques to render only visible items
- Offers more advanced features like infinite loading and multi-column layouts
Cons of react-virtualized
- Steeper learning curve due to its complexity and React-specific implementation
- Requires more setup and configuration compared to list.js
- May be overkill for simpler list rendering tasks
Code Comparison
list.js:
var options = {
valueNames: ['name', 'born']
};
var userList = new List('users', options);
react-virtualized:
import { List } from 'react-virtualized';
<List
width={300}
height={300}
rowCount={1000}
rowHeight={20}
rowRenderer={({ index, key, style }) => (
<div key={key} style={style}>
Row {index}
</div>
)}
/>
Key Differences
- list.js is a vanilla JavaScript library, while react-virtualized is specific to React applications
- react-virtualized focuses on performance optimization for large datasets, whereas list.js is simpler and more lightweight
- list.js provides built-in search and sorting functionality, while react-virtualized requires additional implementation for these features
Use Cases
- Choose list.js for simple list rendering and manipulation in vanilla JavaScript projects
- Opt for react-virtualized when dealing with large datasets in React applications, especially when performance is crucial
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
List.js
Perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML. Really simple and easy to use!
Core idea
- Simple and invisible
- Easy to apply to existing HTML
- No dependencies
- Fast
- Small
- Handle thousands of items
Features
- Works both lists, tables and almost anything else. E.g.
<div>
,<ul>
,<table>
, etc. - Search Read more âº
- Sort Read more âº
- Filter Read more âº
- Simple templating system that adds possibility to add, edit, remove items Read more âº
- Support for Chrome, Safari, Firefox, IE9+
Download / Install
Via NPM
npm install list.js
Via Bower
bower install list.js
Via CDNJS
<script src="//cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script>
Via Direct Download
Questions / How to?
https://stackoverflow.com/questions/tagged/list.js
Demo / Examples
- Existing list
- Existing list + add
- New list
- Add, get, remove
- Fuzzy search
- Pagination
- Search in specific column
- Filter in range
- Show message filter/search results in 0 items
- Only show list after search/filter
Documentation
Thanks to all lovely contributors! Want to join them?
- Read more at listjs.com/overview/contribute
Creator
Jonny Strömberg @javve | |
---|---|
I hope you like the lib. Iâve put a lot of hours into it! Feel free to follow me on Twitter for news and donate a coffee for good karma ;) |
License (MIT)
Copyright (c) 2011-2020 Jonny Strömberg <jonny.stromberg@gmail.com> javve.com
Top Related Projects
An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
Github fork of Christian Bach's tablesorter plugin + awesomeness ~
Tables plug-in for jQuery
DataTables but in TypeScript transpiled to Vanilla JS
React components for efficiently rendering large lists and tabular data
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