Displaying Data from Different Sheets in Google Sheets

Displaying Data from Different Sheets in Google Sheets

Paul624Paul624 Posts: 6Questions: 2Answers: 0
edited August 2022 in Free community support

I have a datatable displaying data from a Google Sheet, which works fine. That's from the default sheet (Sheet1), though.

I want to display data from a different sheet (tab) but can't find how to do that (Goal/Assist or Predicted).

Have attached image showing sheets I'm referring to if it wasn't clear.

FYI I have a very basic understanding of coding so please talk to me as such :)

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,660Questions: 1Answers: 10,094 Site admin

    How are you currently importing the sheet into DataTables?

    Allan

  • Paul624Paul624 Posts: 6Questions: 2Answers: 0

    Javascript, I believe. I can share some of the code if need more information?

  • kthorngrenkthorngren Posts: 20,274Questions: 26Answers: 4,765

    Please share the code so we can see how you are getting the data and importing into Datatables.

    Kevin

  • Paul624Paul624 Posts: 6Questions: 2Answers: 0
    edited August 2022
      <script>
            var key = "https://docs.google.com/spreadsheets/d/e/2PACX-1vRaiTmUKjtQ7MxiGibN2GAZ8m9NHF3IA2U-yE0PhBpCOXHewhs57PrjZO7GQzZvrEGGBW7HFEE43yX0/pub?output=csv";
            var columns = [{"data": "Name"}, {"data": "StartingPredicted"}, {"data": "Team"}, {"data": "Position"}, {"data": "Ownership"}, {"data": "Price"}, {"data": "Fixture"}, {"data": "Start"}];
            $(document).ready(function() {
                function init() {
                    Papa.parse(key, {
                        download: true,
                        header: true,
                        complete: setupTable
                    })
                }
                init();
                var ownership_vals = [20, 15, 10, 5, 2, 1];
                function setupTable(result) {
                    var data = result.data;
                    $('#predicted_starting').dataTable( {
                        "data": data,
                        "columns": columns,
                        "order": [[1, "desc"], [5, "asc"]],
                        "autoWidth": false,
                        initComplete: function () 
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide![]

  • kthorngrenkthorngren Posts: 20,274Questions: 26Answers: 4,765
    Answer ✓

    You are using Papa Parse to get the Google sheets not Datatables. You are using Datatables to display the resulting data. See if this tutorial about using Papa Parse with Google sheets helps with setting up links for the different sheets.

    Kevin

  • Paul624Paul624 Posts: 6Questions: 2Answers: 0
    edited August 2022

    That did answer my question - for those wondering, simply publish to web but select that given sheet only and use the given URL.

    Thank you for the responses.

Sign In or Register to comment.