Create a HTML table from JSON that can be sorted, selected, and post-processed using a simple callback.

Overview

Tidy Table Bower version Build status

Create a HTML table from JSON that can be sorted, selected, and post-processed using a simple callback.

Tidy-Table

Features

  • Extensible HTML/CSS interface.
  • Compatible with all modern desktop and mobile web browsers.
  • Fully responsive layout with touch event support.
  • Easy to set-up and customize.
  • Customizable callback functions for post-processing selected results.
  • Post-process options for manipulating table/column/menu elements.
  • Fast and lightweight (JavaScript plug-in *only 4 kB)

Installation

This package can be easily installed using Bower.

Modern v3 (no dependencies)

$ bower install tidy-table#3

Legacy v2 (requires jQuery 1.8.3)

Compatible with Firefox 3.6, Chrome, Safari 5, Opera, and Internet Explorer 7+ web browsers.

$ bower install tidy-table#2

Please refer to the README for more information about this package.

Developers

CLI options

Minify CSS/JavaScript sources (using Minify):

$ npm run minify

Run JSHint on the script itself:

$ npm run jshint

See Also

This package can be used in conjunction with Poppy-Pagination to create a seamless per-page result experience.

Contributions

If you fix a bug, or have a code you want to contribute, please send a pull-request with your changes. (Note: Before committing your code please ensure that you run npm run jshint)

License and Warranty

This package is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

Tidy-Table is provided under the terms of the MIT license

Author

Marc S. Brooks

Comments
  • menuOptions callback not returning rows after column sort

    menuOptions callback not returning rows after column sort

    My callback function works properly until I sort on a column header. After sorting, the callback function parameter 'rows' is an empty array even though table rows have been selected. Tried setting event breakpoints for mouse click in Chrome debugger, but that's not helping (just runs through the jQuery code). I'm using this with jQuery 2.1.3.

    bug 
    opened by deely3 7
  • How to select the contents in the table cell

    How to select the contents in the table cell

    Thank you very much for this amazing script. I’ve been using it on many of my pages and it really saves me a lot of time. Recently one of my users wants to select the contents in the table cell and do a “ctrl + c”, and he asked me how to select the contents in the table. I tried various ways with no luck. Can you please let me know how to do that?

    Thanks, Victor

    question 
    opened by sweetgishow 4
  • Table mouse hover and down events are disabled

    Table mouse hover and down events are disabled

    I am currently working to add the ability to make the generated tables editable. The inputs I create are not gaining focus when I try editing them and after more checking out the source, I realized the mouse hover and down events on the table were disabled.

    Why are these events on the table disabled?

    question 
    opened by geoffreymuchai 3
  • Table data not refreshing?

    Table data not refreshing?

    I created a table based on the demo, snippet below.

    Clicking a button pulls back data from a remote store, which is then used to populate the table. The table populates with data the first time the button is clicked, but subsequent clicks do not refresh the table.

    I can see the data being refreshed with each button click via the console output on line 18. However, the table does not reflect the new dataset. The only apparent way to flush the data is by reloading the page.

    01        $(function () {
    02          $("#btnShow").click(function(event) {
    03
    04            var callback = function(data) {
    05              result = $.parseJSON(data);
    06              if (result.success) {
    07                payload = $.parseJSON(result.data);
    08                var columnTitles = [];
    09                var columnValues = [];
    10                $.each(payload, function( index, value ) {
    11                  var tmpArray = [];
    12                  $.each( value, function( key, value ) {
    13                    if (index === 0) columnTitles.push(key);
    14                    tmpArray.push(value);
    15                  })
    16                  columnValues.push(tmpArray);
    17                });
    18                console.log(columnValues);
    19
    20                $('#tidy-table').html('');
    21                var block = $('#tidy-table')
    22                  .TidyTable({
    23                    enableCheckbox: true,
    24                    enableMenu:     false
    25                  },
    26                  {
    27                    columnTitles: columnTitles,
    28                    columnValues: columnValues,
    29
    30                    // pre-process column values before sort (optional)
    31                    sortByPattern: function(col_num, val) {
    32                      if (col_num != 1) return val;
    33
    34                      return String(val).replace(/$|%|#/g, '');
    35                    }
    36                  });
    37
    38                // copy the table options menu
    39                var menu = $('select.tidy_table', block).clone(true);
    40                block.append(menu);
    41
    42                // optional animation
    43                block.slideDown('fast');
    44
    45                // remove stored data
    46                block.TidyTable('destroy');
    
    question 
    opened by JacquesPerrault 2
  • Sorting numbers with

    Sorting numbers with "thousand" separators

    I have a table that displays numbers with spaces as thousand separators e.g., 2 300.

    When sorting these columns, the values are treated as strings not numbers, so an ascending sort might look something like:

    2 2 300 3 4

    instead of:

    2 3 4 2 300

    In my case I can workaround this by changing the regexs in the sortByColumn method by adding spaces:

    /$|%|#/g

    becomes:

    /$|%|#| /g

    For a more I18n compliant solution however, other possible thousand separators should be supported (typically "," US and "." FR). The difficulty here is that decimal separators, typically "." or "," could also be removed and mess up the values.

    I'd therefore suggest making additional configuration options so that the regex can be customised.

    enhancement 
    opened by sauy7 2
  • Bump lodash from 4.17.14 to 4.17.19

    Bump lodash from 4.17.14 to 4.17.19

    Bumps lodash from 4.17.14 to 4.17.19.

    Release notes

    Sourced from lodash's releases.

    4.17.16

    Commits
    Maintainer changes

    This version was pushed to npm by mathias, a new releaser for lodash since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    opened by dependabot[bot] 1
  • New Task: Replaced packer module with uglify due to lack of NPM support (deprecation)

    New Task: Replaced packer module with uglify due to lack of NPM support (deprecation)

    Issue

    To put it simply.. :fire:Dependency hell :fire:

    The Tidy-Table dependency packer which is used by this script for minification relies on a dependency chain of the following unsupported packages:

    Due to this, when installing this package using modern versions of NPM you will likely receive the following error:

    npm ERR! [email protected] install: `node-gyp rebuild`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] install script.
    

    Solution

    This package, including minifier, should be replaced with uglify since it can handle both JavaScript/CSS minification (and they are fully supported).

    If there is anyone that wants to take the lead on this, be my guest, or I will address this when time becomes available.

    bug 
    opened by nuxy 1
  • Color table rows based on condition

    Color table rows based on condition

    Would like to see some documentation how to set the color of a row based on a condition that is met.

    For example if I wanted all rows that have a negative value to be red, and positive green?

    question 
    opened by j-flowers 1
  • postProcess row function

    postProcess row function

    Is it possible to assign a function to a row (rather than column) in the postProcess object? Or, is it only possible using the menu callback? I'd like to: 1) highlight hovered rows and 2) assign a function to the onclick event of a row.

    question 
    opened by deely3 1
  • Wrong detection of jQuery version

    Wrong detection of jQuery version

    I use jQuery in version "1.11.0" and got error: "Tidy-Table requires jQuery 1.8.3 or greater."

    if (!window.jQuery || (window.jQuery && window.jQuery.fn.jquery < '1.8.3')) {
        throw new Error('Tidy-Table requires jQuery 1.8.3 or greater.');
    }
    

    This will raise error for version of jQuery "1.10.", "1.11."

    bug 
    opened by dbackowski 1
  • Porting JSON data to Tidy-Table

    Porting JSON data to Tidy-Table

    How do you actually call JSON data to write to the a table created by Tidy-Table? In your sample table, you provide the data array within the script, but you don't actually show how to bring data in with a JSON URL

    For example I would like to use the data from the following JSON source in conjunction with Tidy-Table:

    http://query.yahooapis.com/v1/public/yql?q=select%20symbol%2C%20EnterpriseValue%2C%20Symbol%2C%20MarketCap%20from%20yahoo.finance.keystats%20where%20symbol%20in%20(%22ABX%22%2C%22GG%22%2C%22NEM%22%2C%22KGC%22)%20%7C%20sort(field%3D%22EnterpriseValue%22%2C%20descending%3D%22true%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=topstock
    

    How would I incorporate this URL into the Tidy-Table script?

    question 
    opened by frontiercarlos 1
Owner
Marc S. Brooks
I never sleep :zzz:
Marc S. Brooks
Move all the disks from the left hand post to the right hand post, only moving the disks one at a time and a bigger disk can never be placed on a smaller disk.

Hanoi Tower Description The Tower of Hanoi was a famous problem posed by a mathematician in 1883, The "puzzle" is to move all the disks from the left

Dustin J Sellers 1 Feb 5, 2022
Input a list of Handshake top-level domains, outputs names sorted into 4 arrays: available, registered, reserved, or invalid.

name-check A simple NodeJS package that, given a flat list of top-level domain names, queries the Handshake (HNS) blockchain in order to classify each

Neel Yadav 2 Jan 8, 2022
Simple modern JavaScript ES6 library that fetches JSON data into an HTML table which displays nicely within a Bootstrap 4 Card.

Simple modern JavaScript ES6 library that fetches JSON data into an HTML table which displays nicely within a Bootstrap 4 Card. Uses simplenotsimpler/modern-table library.

SimpleNotSimpler 6 Feb 17, 2022
Create Bootstrap 5 Modal Box using JavaScript with custom title, description, button labels and custom YES button callback

Dynamic BS5 Modal Box Create Bootstrap 5 Modal Box using JavaScript with custom title, description, button labels and custom YES button callback Insta

null 5 Oct 23, 2022
Another table select prompt plugin of inquirer.js, with powerful table render and filters.

inquirer-table-select-prompt Table row selection prompt for Inquirer.js 动机 现有的 inquirer.js 没有支持表格行选中的命令行交互的插件. 社区内能查找到的,只有一个二维数组的 checkbox,eduardobouc

锂电 3 Jan 7, 2023
Types generator will help user to create TS types from JSON. Just paste your single object JSON the Types generator will auto-generate the interfaces for you. You can give a name for the root object

Types generator Types generator is a utility tool that will help User to create TS Interfaces from JSON. All you have to do is paste your single objec

Vineeth.TR 16 Dec 6, 2022
JCS (JSON Canonicalization Scheme), JSON digests, and JSON Merkle hashes

JSON Hash This package contains the following JSON utilties for Deno: digest.ts provides cryptographic hash digests of JSON trees. It guarantee that d

Hong Minhee (洪 民憙) 13 Sep 2, 2022
This project is built with JavaScript, Webpack, HTML & CSS, Leaderboard api. When user clicks on Refresh button it hits the api and responds with the data, The user can also post data to the api

leaderboad Description the project. this project is about the leaderboad i did during Microverse to build a website for adding Data to the API and fet

Emmanuel Moombe 4 May 30, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022
This Lens Protocol module allows you to create a Transparent Promotion system in which the post creator can add a reward for who (ex: influencers) mirror it.

promote-module (in progress) This Lens Protocol module allows you to create a Transparent Promotion system in which the post creator can add a reward

Alessandro Manfredi 9 Oct 2, 2022
Elizabeth Oyinlade Ojesanmi 10 Sep 14, 2022
Simple patch that adds a 'progress' callback to jquery Ajax calls

Jquery Ajax Progresss A simple patch to jQuery that will call a 'progress' callback, using the XHR.onProgress event Usage Simply include the script on

Chad Engler 118 Sep 8, 2022
A simple and basic app, where you can add your todo list and remove all selected or one of the items from the list

A simple and basic app, where you can add your todo list and remove all selected or one of the items from the list

Sediqullah Badakhsh 13 Jun 14, 2022
Pretty-print-json - 🦋 Pretty-print JSON data into HTML to indent and colorize (written in TypeScript)

pretty-print-json Pretty-print JSON data into HTML to indent and colorize (written in TypeScript) 1) Try It Out Interactive online tool to format JSON

Center Key 87 Dec 30, 2022
Prisma 2+ generator to emit a JSON file that can be run with json-server

Prisma JSON Server Generator A Prisma generator that automates creating a JSON file that can be run as a server from your Prisma schema. Explore the o

Omar Dulaimi 14 Jan 7, 2023
JavaScript micro-library: pass in an element and a callback and this will trigger when you click anywhere other than the element

Add a click listener to fire a callback for everywhere on the window except your chosen element. Installation run npm install @lukeboyle/when-clicked-

Boyleing Point 5 May 13, 2021