|
| 1 | +//Edit 'key' and 'columns' to connect your spreadsheet |
| 2 | + |
| 3 | +//enter google sheets key here |
| 4 | +//var key = "https://docs.google.com/spreadsheets/d/113QZOTS9JQ1WGfwjwQrOpErUBJTAnaBmdjP0_OjA53c/pubhtml?gid=489792061&single=true"; |
| 5 | +//var key = "https://docs.google.com/spreadsheets/d/1azEpwRap_KPLvErTATEkBdZyt79nnDWahsTG4X3OqVI/pubhtml?gid=0&single=true"; |
| 6 | +var key = "https://docs.google.com/spreadsheets/d/1KaCmBzgGr6KpadTU5YcclARC6zJfX19rM2d8Hd7MQag/pubhtml?gid=0&single=true"; |
| 7 | + |
| 8 | + |
| 9 | +//"data" refers to the column name with no spaces and no capitals |
| 10 | + //punctuation or numbers in your column name |
| 11 | +//"title" is the column name you want to appear in the published table |
| 12 | +var columns = [ |
| 13 | + { "data": "publisher", "title": "Publisher" }, |
| 14 | + { "data": "scope", "title": "Scope" }, |
| 15 | + { "data": "waivereligibilitycriteria", "title": "Waiver Eligibility Criteria" }, |
| 16 | + { "data": "waivereligibilitymode", "title": "Waiver Eligibility Mode" }, |
| 17 | + { "data": "waiveramount", "title": "Waiver Amount" }, |
| 18 | + { "data": "waiverapplicationprocess", "title": "Waiver Application Process" }, |
| 19 | + { "data": "sourcelink", |
| 20 | + "render":function(data, type, row, meta){ |
| 21 | + if(type === 'display'){ |
| 22 | + data = '<a href="' + data + '" target = _blank>' + "Link 🔗" + '</a>'; |
| 23 | + } |
| 24 | + return data; |
| 25 | + }, |
| 26 | + "title": "Link" }, |
| 27 | + { "data": "otheropensciencepractices", "title": "Other OpenScience Practices" }]; |
| 28 | + |
| 29 | +$(document).ready(function() { |
| 30 | + |
| 31 | + function initializeTabletopObject(){ |
| 32 | + Tabletop.init({ |
| 33 | + key: key, |
| 34 | + callback: function(data, tabletop) { |
| 35 | + writeTable(data); //call up datatables function |
| 36 | + }, |
| 37 | + simpleSheet: true, |
| 38 | + debug: false |
| 39 | + }); |
| 40 | +} |
| 41 | + |
| 42 | + initializeTabletopObject(); |
| 43 | + |
| 44 | + function writeTable(data){ |
| 45 | + //select main div and put a table there |
| 46 | + //use bootstrap css to customize table style: http://getbootstrap.com/css/#tables |
| 47 | + $('#graphic').html('<table cellpadding="0" cellspacing="0" border="0" id="mySelection"></table>'); |
| 48 | + |
| 49 | + //initilize the DataTable object and put settings in |
| 50 | + $("#mySelection").DataTable({ |
| 51 | + "data": data, |
| 52 | + "columns": columns, |
| 53 | + // "columnDefs": [ |
| 54 | + // { "visible": false, "targets": 7 } |
| 55 | + // ], |
| 56 | + //"order":[[1, "desc"]], //order on 1st column |
| 57 | + "pagingType": "simple" //no page numbers |
| 58 | + //uncomment these options to simplify your table |
| 59 | + //"paging": false, |
| 60 | + //"searching": false, |
| 61 | + //"info": false |
| 62 | + }); |
| 63 | + } |
| 64 | +}); |
| 65 | +//end of writeTable |
| 66 | + |
| 67 | + |
| 68 | + |
0 commit comments