Giter Site home page Giter Site logo

chrislkeller / _tabletop_to_datatables Goto Github PK

View Code? Open in Web Editor NEW
25.0 6.0 20.0 324 KB

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

Home Page: http://projects.chrislkeller.com/demos/tabletop_to_datatables

_tabletop_to_datatables's Introduction

Demo: tabletop to datatables

This repo's location has changed, though the zip file added to this repo contains the same code from the link above...

In addition, Scott Pham has created a version of this project that uses the latest version of DataTables and removes a lot of deprecated code.

_tabletop_to_datatables's People

Contributors

chrislkeller avatar csessig86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

_tabletop_to_datatables's Issues

"Website" data column and sorting issues

Hi! I am trying to create a live-updating list of blogs that accept guest bloggers for my company website, and have run into a few problems - first, every entry in the "Contact" column shows up as hyperlinked text that reads "website", and the link goes nowhere.

Also, in the column of Alexa ranking data, the entries don't sort properly - it's like they're sorting by first number rather than value or something along those lines. I've copied and pasted the script below, any help would be greatly appreciated!


var jqueryNoConflict = jQuery;

// begin main function
jqueryNoConflict(document).ready(function(){

    initializeTabletopObject("https://docs.google.com/spreadsheets/d/1wEZ9T6Kt-0PRx2D7-TtpeyQ4ecCYOssMuer9YSyez70/pubhtml");

});

// pull data from google spreadsheet
function initializeTabletopObject(dataSpreadsheet){
    Tabletop.init({
        key: dataSpreadsheet,
        callback: writeTableWith,
        simpleSheet: true,
        debug: false
    });
}

// create table headers
function createTableColumns(){

    /* swap out the properties of mDataProp & sTitle to reflect
    the names of columns or keys you want to display.
    Remember, tabletop.js strips out spaces from column titles, which
    is what happens with the More Info column header */

    var tableColumns =   [
        {"mDataProp": "outlet", "sTitle": "Outlet", "sClass": "center"},
        {"mDataProp": "guidelines", "sTitle": "Guidelines", "sClass": "center"},
        {"mDataProp": "contact", "sTitle": "Contact", "sClass": "center"},
        {"mDataProp": "specialnotes", "sTitle": "Special Notes", "sClass": "center"},
        {"mDataProp": "alexa", "sTitle": "Alexa", "sClass": "center"},
        {"mDataProp": "pagerank", "sTitle": "Pagerank", "sClass": "center"},
        {"mDataProp": "tweets", "sTitle": "Tweets", "sClass": "center"},
        {"mDataProp": "facebooklikes", "sTitle": "Facebook Likes", "sClass": "center"}
    ];
    return tableColumns;
}

// 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({
        "sPaginationType": "bootstrap",
        "iDisplayLength": 25,
        "aaData": dataSource,
        "aoColumns": createTableColumns(),
        "fnRowCallback": function(nRow, aData, iDisplayIndex) {
            console.log(aData);
            $("td:eq(2)", nRow).html("<a href='http://" + aData.website + "'>Website</a>");
            return nRow;
        },
        "oLanguage": {
            "sLengthMenu": "_MENU_ records per page"
        }
    });

};

//define two custom functions (asc and desc) for string sorting
jQuery.fn.dataTableExt.oSort["string-case-asc"]  = function(x,y) {
    return ((x < y) ? -1 : ((x > y) ?  0 : 0));
};

jQuery.fn.dataTableExt.oSort["string-case-desc"] = function(x,y) {
    return ((x < y) ?  1 : ((x > y) ? -1 : 0));
};

Translation?

Hello!

I am not able to fully translate the table in French.

Here is an example on my website:
http://naelshiab.com/special/terrains/terrains.html

As you can see, I've been able to change most of it by modifying the scripts, but I am not able to find where to change "Search" and "Showing 1 to 25 of 1,699 entries".

Any idea?

Thank you! :)

Lazy Loading Support

I liked this project but It does not support lazy loading. As of now this is not possible for Large Data-sets.

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.