Giter VIP home page Giter VIP logo

sdcat's Introduction

Demo: tabletop to datatables

Use Tabletop.js to pull json from Google Spreadsheet and feed it to the DataTables jQuery plugin.

Demo by Chris Essig & Chris Keller made possible thanks to the Open Source work of Built By Balance & Allan Jardine.

If interested in an enhanced version that allows you to choose between using a flat JSON file or tabletop.js to pull data from a Google spreadsheet, here's a draft version.


Step 1 - Prepare Google Spreadsheet data.

Step 2 - Add your spreadsheet key as an argument to the initializeTabletopObject function that is fired on document ready.

    initializeTabletopObject('0An8W63YKWOsxdHVreXpLbVRWUGlJUlcweHVfZ01ycVE');

Step 3 - Set up your DataTables column headers in by adjusting the array in the createTableColumns() function. You'll be changing the value for both the mDataProp and sTitle keys.

    var tableColumns =   [
		{'mDataProp': 'brewery', 'sTitle': 'Brewery', 'sClass': 'center'},
		{'mDataProp': 'city', 'sTitle': 'City', 'sClass': 'center'},
		{'mDataProp': 'website', 'sTitle': 'Website', 'sClass': 'center'}
	];

Step 4 - Push the data to the table in tabletop_feed.js. I am creating a table with an id of data-table-container in the #demo div. I am then writing the datatable to that data-table-container div.

    // create the table container and object
    function writeTableWith(dataSource){
        jqueryNoConflict('#demo').html('<table cellpadding="0" cellspacing="0" border="0" class="display table table-bordered table-striped" id="data-table-container"></table>');

        var oTable = jqueryNoConflict('#data-table-container').dataTable({
            'aaData': dataSource,
            'aoColumns': createTableColumns()
        });
    };

Links & Resources

sdcat's People

Contributors

septapod avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.