A more-fun, semantic, alternative to datatables

Overview

jQuery Dynatable

A funner, semantic, HTML5+JSON, interactive table plugin.

See the full documentation with demos.

Why?

The purpose of Dynatable is to provide a simple, extensible API, which makes viewing and interacting with larger datasets easy. Dynatable provides a framework for implementing the most common elements out of the box, including sorting, searching and filtering. Above all, I wanted a clean and elegant API that is fun to use.

Quickstart

To install Dynatable:

Support

IRC: Join us at #dynatable on freenode IRC

Bugs and Feature Requests: Search and open a Github Issue

Debugging: Fork and edit this template on JSFiddle

Questions: Ask a question tagged with dynatable on StackOverflow

TODO:

  • Change unfilters and filters to readers and writers.
  • Clean up defaults that are functions, by abstracting into internal named functions which can be re-used.
  • Change default sort functions to underscore-namespaced functions so as not to conflict with record attributes called e.g. search.
  • Update sort function implementation to be analogous to search function implementation (whereby if a sort function matching attribute name is present, it will be used for that attribute by default).
  • Namespace pushstate query parameters by dynatable instance id to simplify refreshQueryString function and prevent conflicts between multiple pushState-enabled instances on one page.
  • Refactor using prototype to abstract dynatable-global functions to improve memory efficiency for multiple instances on one page.
  • Implement configurable sorting algorithm (see JS Merge Sort and Sorting Table).
  • Change from Object.create method to constructor pattern to improve performances (see benchmark).
  • Use for loops instead of $.each where possible to improve performance.
  • Use strings and/or document fragments for writing to DOM, instead of jQuery, by default to improve writing performance.
  • Use templated strings to write pagination and other inputs.
  • Make class names for input elements configurable.
  • Use Chrome profiler to find any performance bottlenecks and fix.
  • Simplify API by separating internal-only and accessible model functions.
  • Move sorts and queries functions objects to defaults to make easier to customize and add to on instantiation (like filters and unfilters)
  • Try using CSS-only for ProcessingIndicator.position to avoid querying rendered DOM styling and speed up all operations that position the indicator (see CSS absolute centering).
  • Add data-dynatable-attr="name" support for reading records from arbitrary markup (so that you don't need to write a custom rowReader function when starting with e.g. a stylized list).
  • Make sort function first lookup settings.sortTypes[attr], then look directly for sort sorts.functions[attr], and then finally sorts.guessType only if neither of the first two exist.
  • Add global remove/cleanup function (opposite of init) to allow removing dynatable via JS.
  • Support for Zepto?

Tests

Currently the testing process consists of opening the Dynatable documentation (source code here) in each browser and making sure every example works. This is fine for the initial release, since it serves the dual purpose of helping us write the documentation and having a written functional use-case at once. However, one of the top priorities now is to automate each use-case in the docs as a test case within an automated test suite.

If anyone out there thinks this sounds like fun, please contact me or even go ahead and create an issue/pull request. Otherwise, it will be at the top of my priority list until I can get to it.

Contributing

Please see the Contributing Guidelines.

Author

Steve Schwartz - JangoSteve on Github, @jangosteve on Twitter

Alfa Jango logo Alfa Jango Open Source - @alfajango on Twitter

Copyright and License

Copyright 2014 Alfa Jango LLC.

Dual licensed, released under the Free Software Foundation's GNU Affero General Public License (AGPL), or see license information for proprietary or commercial applications.

Miscellaneous

Refactor performance benchmarks

For version 0.1.0, Dynatable went through a refactor to use prototypal inheritence as a more memory-efficient foundation. Here are some off-the-cuff benchmarks I set up when doing this.

The performance increase was modest, according to these benchmarks, but more importantly, the code became a bit cleaner and easier to work with.

http://jsperf.com/dynatable-prototypal-refactor

http://jsperf.com/dynatable-refactor/3

Currently, there's still a bit of performance improvement to be gained by further grouping DOM reads and writes (though they're already mostly grouped together), and by using JS string concatenation instead of jQuery to build the HTML for rendering step.

The new string concatenation has started to roll out in v0.2.

Comments
  • Add css class to dynatable columns

    Add css class to dynatable columns

    I'm trying to add a class name to dynatable generated <td>s, but I don't know how. I've tried this, but does not work:

    <table id="my-final-table">
      <thead>
        <th>Band</th>
        <th>Song</th>
          <th style="display:none;" class="td-id">id</th>
      </thead>
      <tbody>
      </tbody>
    </table>
    

    I want to add td-id to the last <td>.

    var jsondata=[
      {
        "band": "Weezer",
        "song": "El Scorcho",
          "id":1
      },
      {
        "band": "Chevelle",
        "song": "Family System",
          "id":2
      }
    ];
    
    var processingComplete = function(){
        $('#my-final-table tr').on("click",function(){
            console.log($(this));
    });
    };
    $('#my-final-table').dynatable({
      dataset: {
        records: jsondata
      }
    }).bind('dynatable:afterProcess', processingComplete);
    
    processingComplete();
    

    But the row html is like this when I click on a row:

    <td style="text-align: center;">Chevelle</td>
    <td style="text-align: center;">Family System</td>
    <td style="display: none;text-align: start;">2</td>
    

    JSFiddle: http://jsfiddle.net/maysamsh/pDVvx/5/

    opened by maysamsh 13
  • Example AJAX setup and response in documentation

    Example AJAX setup and response in documentation

    I realize the demo omits this, but we aren't able to get this to work properly. Pagination seems to be broken and we are unable to navigate pages. Not sure how people are using dynatables, but we'd love to use it as an ajax replacement for Datatables.

    $('#homes-table').dynatable({
      features: {
        paginate: true
      },
      dataset: {
        ajax: true,
        ajaxUrl: '<%= homes_path %>',
        ajaxOnLoad: true,
        records: []
      },
      params: {
        sorts: 'order',
        page: 'page',
        perPage: 'per_page',
        queryRecordCount: 'count',
        totalRecordCount: 'total_count'
      },
      table: {
        defaultColumnIdStyle: 'underscore'
      },
      inputs: {
        paginationClass: 'pagination',
        paginationActiveClass: 'active',
        paginationDisabledClass: 'disabled'
      }
    });
    

    Current JSON response

    {
    "records": [
      {
        "name": "1 Testing Ave",
        "customer": "<a href='/customers/2'>Eric Customer 2</a>",
        "development": "Inglewood",
        "actions": "<a class='btn btn-info btn-block btn-xs' href='/homes/4'>View</a>"
      },
    ],
    "count": 10,
    "total_count": 29
    }
    
    opened by ericchernuka 9
  • the queryRecordCount parameters not necessary

    the queryRecordCount parameters not necessary

    We only need to count the queryRecordCount once when page === 1. If we change to other pages this variable stay the same and doesn't need to be compute by the backend.

    The best one would be to have a button 'last page' and never have to compute queryRecordCount.

    opened by mnowik 8
  • Integrate with Sharepoint 2013 App (JSOM)

    Integrate with Sharepoint 2013 App (JSOM)

    I've managed to Dynatable into the SP2013 app I'm building and whilst the HTML table is being "Dynafied" I'm seeing all the records (252) and when I click the link to sort the column the data disappears.

    Would this be something to do with how SP is bring back the data? I'm using JSOM to present the data.

    opened by CampbellNash 8
  • Adding inputs option for

    Adding inputs option for "Search:" label

    Hi !

    I'm using dynatable for my website and I just saw that the label "Search:" near the search field is not easily changeable.

    So I create an option, just like you did at first, to modify the label.

    I tested it just now and it's working great.

    I hope it will fill your requirements.

    Thank you for your work.

    Added an input option to modify the "Search:" label near the search field.

    opened by LouWii 8
  • Problems using custom rowWriter with Markup.js, content ends up outside <tbody></tbody>

    Problems using custom rowWriter with Markup.js, content ends up outside

    Hi there.

    I am experiencing a very odd problem trying to use Markup.js in my custom rowWriter. My code works fine when just returning a string ala.

    return "<tr><td>" + record.ident + "</td><td>" + record.first_name + " " + record.last_name + "</td><td>" + record.open_incidents + " åpne saker</td><td><button data-id='" + record.id + "' class='process_button btn btn-success btn-xs'>Behandle</button></td></tr>";
    

    Using the code above in a custom rowWriter, like this, https://gist.github.com/flexd/427ac875d96735f2711c

    It looks like this, without_templating

    But, if I use Markup.js to generate the HTML string using the commented out code in the gist above, it looks like this: with_templating

    As you can see in the second screenshot, the row has now somehow ended up outside <tbody></tbody>

    I am not sure why this happens, as you can see here https://gist.github.com/flexd/333768cabcb5f7462ae2 Both methods return proper HTML, the only difference is that the template is formatted to be readable.

    Looking at the default rowWriter and the source code, I have not yet found out what may be causing this, but since Markup.js seems to return a perfectly good HTML string I believe the problem exists within dynatable at the moment, I may of course be wrong.

    https://github.com/alfajango/jquery-dynatable/blob/master/jquery.dynatable.js#L373

    I am on IRC for the next 4-5 hours today and a while during the day tomorrow (CET). :-)

    opened by flexd 7
  • How do i display the table

    How do i display the table

    If the AJAX JSON data is something like this how do i display the data in the table. Currently the AJAX example you have has a parent JSON identifier called records. How would you process the data without that parent.

    [{"band": "Weezer","song": "El Scorcho"},
    {"band": "Chevelle","song": "Family System"}]
    
    
    
    
    opened by kyoukhana 7
  • Dynamically add links to dynatable

    Dynamically add links to dynatable

    I don't have links in my json but i would like each row in my table to have a href added to it.

    Can anyone point me to an example of how this can be implimented please?

    Thanks.

    opened by akzogibbs 5
  • resetting page number when sorting

    resetting page number when sorting

    Hi !

    I was wondering if there is an option to set the page number to 1 when the user is sorting the table.

    I think that keeping the same page number when changing sort is quite confusing.

    Thanks

    opened by LouWii 5
  • Swapped `readers._rowReader` with `writers._rowWriter`

    Swapped `readers._rowReader` with `writers._rowWriter`

    In the documentation, it says

    NOTE: We'll also need a readers._rowReader function to tell dynatable how to write the JSON records back to the page, but we'll get to that in the Render section.

    I'm pretty sure that what was meant was

    NOTE: We'll also need a writers._rowWriter function to tell dynatable how to write the JSON records back to the page, but we'll get to that in the Render section.

    since this NOTE comes right after talking about the readers._rowReader, and it doesn't make sense to say "we'll also need what we just told you all about" and because the Render section introduces writers._rowWriter.

    I didn't see a repo (or a branch) for the docs, so I'm posting the issue here. I hope that's not a problem.

    opened by brandondrew 4
  • Add 'dynatable-loaded' class to table when processing is complete

    Add 'dynatable-loaded' class to table when processing is complete

    I needed this to avoid having the original table flash up before Dynatable had finished working on it. e.g. with

    #some-table {
       visibility: hidden;
    }
    
    #some-table.dynatable-loaded {
        visibility: visible;
    }
    

    but debating whether it deserves to be in the core or my own event handler instead.

    opened by Virakal 4
  • upgrade JQuery to 3.6

    upgrade JQuery to 3.6

    This PR upgrades the dependency jQuery to 3.6.0 and resolve the following deprecation issues due to upgrading

    • .error -> .on("error", handler)
    • .bind -> .on
    • .delegate -> .on
    • .undelegate -> .off
    • .isArray -> Array.isArray
    • .trim(text) -> text.trim()
    opened by KedoKudo 0
  • Looks like www.dynatables.com is down.

    Looks like www.dynatables.com is down.

    Is the website going to return or is there some documentation elsewhere.

    I'm guessing it has been down for awhile as I couldn't see a google cache of it either.

    opened by sandles 1
  • features.sorting vs features.sort

    features.sorting vs features.sort

    Examples in homepage refer to a features.sorting property, but it's not in the code. I think it should be features.sort instead. Anyone else noticed this? Thanks

    opened by ghost 0
  • creat link from url in json array

    creat link from url in json array

    In our json array we have urls that link to specific pages. How can I add this links to a button in the table?

    <table id="job-table" class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>title</th>
                                    <th>absolute_url</th>
                                    <th>jobLink</th>
                                    <th>locationName</th>
                                    <th>updated_at</th>
                                    <th>id</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <script>
                            var $dataTable = $('#job-table');
                            $.getJSON('https://boards-api.greenhouse.io/v1/boards/oni/jobs', ({jobs}) => {
                                if (!jobs) return;
                                const flattenJobs = jobs.map(({title, absolute_url, location, updated_at, id}) => ({
                                    title,
                                    absolute_url,
                                    updated_at,
                                    locationName: location.name, 
                                    id
                                }));
    
                                console.log(flattenJobs);
                                $dataTable.dynatable({
                                    dataset:{
                                        records: flattenJobs
                                    },
                                    features: {
                                        paginate: true,
                                        recordCount: true,
                                        sorting: true,
                                        search: true,
                                    }
                                });
                            });
                        </script>
    

    Sample json

    jobs: 
      0:  
    absolute_url: "https://oni.bio/careers?gh_jid=4195285002"
    internal_job_id: 4172877002
    location:  
    name: "Oxford"
    metadata: []
    id: 4195285002
    updated_at: "2019-08-27T10:00:41-04:00"
    requisition_id: null
    title: "Account Manager"
    1:  
    absolute_url: "https://oni.bio/careers?gh_jid=4365372002"
    internal_job_id: 4305685002
    location: 
    name: "Oxford"
    metadata: []
    id: 4365372002
    updated_at: "2019-09-03T11:41:03-04:00"
    requisition_id: null
    title: "Backend Software Engineer (DevOps)"
    2:  
    absolute_url: "https://oni.bio/careers?gh_jid=4187013002"
    internal_job_id: 4165585002
    location:  
    name: "Oxford"
    metadata: []
    id: 4187013002
    updated_at: "2019-08-27T10:00:41-04:00"
    requisition_id: null
    title: "C++ Software Engineer"
    
    opened by Wicko-Design 0
Owner
Alfa Jango, LLC
We help you build your startup.
Alfa Jango, LLC
🔑 Keagate is an open-source, high-performance alternative to popular cryptocurrency payment gateways such as Coinbase Commerce, CoinGate, BitPay, NOWPayments, CoinRemitter, CoinsPaid and more.

⛩️ Keagate – A High-Performance Cryptocurrency Payment Gateway ?? This project is actively in development ?? Table of Contents About the Project Purpo

null 76 Jan 3, 2023
Semantic Release plugin to create and publish NuGet packages.

semantic-release-nuget semantic-release plugin to create and publish a NuGet package. Step Description verifyConditions Verify the presence of the NUG

DroidSolutions 6 Jan 2, 2023
The Blitz.js Recipe for installing @semantic-release/github.

semantic-release-github The Blitz.js Recipe for installing @semantic-release/github. blitz install custom-recipes/semantic-release-github -y More info

Custom Recipes 1 Apr 9, 2022
Node starter kit for semantic-search. Uses Mighty Inference Server with Qdrant vector search.

Mighty Starter This project provides a complete and working semantic search application, using Mighty Inference Server, Qdrant Vector Search, and an e

MAX.IO LLC 8 Oct 18, 2022
Backgrid.js is a set of components for building semantic and easily stylable data grid widgets

Backgrid.js is a set of components for building semantic and easily stylable data grid widgets. It offers a simple, intuitive programming interface that makes easy things easy, but hard things possible when dealing with tabular data.

Cloudflare Archive 2k Nov 21, 2022
⚡️🦕 A version semantic and fast package delivery network for Deno.

Deno PKG A version semantic and fast package delivery network for Deno. Examples Using a fixed version: https://pkg.deno.dev/[email protected]/fs/mod.ts htt

迷渡 9 Aug 14, 2022
Semantic is a UI component framework based around useful principles from natural language.

Semantic UI Semantic is a UI framework designed for theming. Key Features 50+ UI elements 3000 + CSS variables 3 Levels of variable inheritance (simil

Semantic Org 50.3k Jan 7, 2023
Retrieve paper citatation data from doi.org and Semantic Scholar.

citation-query Retrieve paper citatation data from doi.org and Semantic Scholar. Install Requires at least Node.js v14.14.0. npm install @uwdata/citat

UW Interactive Data Lab 6 Sep 30, 2022
The world of cryptocurrencies is diverse and becoming more and more popular

We are providing an user with a simple learning resource for an intro into the CryptoCurrency World. Along with a community grown message board to assist with further learning.

null 3 Jun 20, 2022
created a very simple blockchain. just for fun.

SimpleBlockChain created a very simple blockchain. just for fun. Run: node main.js What happens? basically we create a new blockchain, and later we ad

null 1 Dec 25, 2021
A2er - Fun browser extension, changing all words ending with `a` to end with `er`.

a2er Fun browser extension, changing all words ending with a to end with er. This started as a joke between friends and me, pronouncing words ending w

Sebastian Schicho 1 Jan 10, 2022
A fun and functional way to write regular expressions (RegExp)

funexp A fun and functional way to write regular expressions (RegExp). FunExp is a useful tool for larger projects that depends on RegExp to do heavy

Matheus Giovani 2 Feb 7, 2022
Fun λ functional programming in JS

fp-js JavaScript Functional Programming Motivation This purposed for learning functional programming (just that). Features Auto-Curry Option Tooling s

RiN 6 Feb 4, 2022
A simple inefficient and buggy JSON parser written in JavaScript. Just a fun project

A simple inefficient and buggy JSON parser written in JavaScript This JSON parser isn't guaranteed to work properly. Its recommended to use builtin JS

Pranav Baburaj 2 Feb 20, 2022
Master Collection NFT. Mints NFTs on Ethereum containing unique combination of titles for fun.

Master NFT Collection Master NFT Collection is an NFT minting platform that mints NFTs that contain a unique combination of snazzy titles just for fun

MJ LEE 2 Mar 22, 2022
🌸 A fast and fun way to learn Japanese alphabets: hiragana & katakana. Don't wait - learn now!

Sakurator | Start learning 日本語 here Sakurator (Website publish date: ~4-6 April '22) - a personal trainer for learning Japanese alphabets (hiragana &

Anatoly Frolov 3 Jun 22, 2022
TypeScript Fun ! ctions Simple Math

TypeScript Fun ... ctions with "Simple" Math Up and running npm install npm i # se quiser economizar 200 nanosegundos yarn # se for do time Yarn Bad,

Ibrahim Cesar 23 Nov 2, 2022
Fun website to challenge naming all districts in Nepal.

Nepal-Districts Live: https://districts.aabishkararyal.com Repo: https://github.com/aabishkaryal/nepal-districts Table Of Content: Inspiration: Techno

Aabishkar Aryal 39 Dec 25, 2022