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));
};