1
votes

I'm trying for a few days now and I can't figure out how to load a Google Sheets document into Tabulator.

What I did:

My Tabulator code:

    var table = new Tabulator("#baanrecords", {
        ajaxConfig:{
            mode: 'no-cors',
            method:'GET',
            credentials: 'same-origin',
            headers: {
                'Content-type': 'application/json; charset=UTF-8',
                'Accept': 'application/json',
                'X-Requested-With': 'XMLHttpRequest'
            },
        },
        ajaxURL: 'https://spreadsheets.google.com/feeds/list/1Ze31_SUFd0ZyqeG1mt1qrEU61onnYhmI9mR1BC1pM7Y/od6/public/values?alt=json',
        height:'400px',
        layout:'fitColumns',
        autoColumns:true,
        placeholder:'De records worden geladen, een moment...',
        index: 'onderdeelnaam',
        columns:[
            {title:"Onderdeel", field:"gsx$onderdeelnaam", sorter:"string", width:200},
            {title:"Prestatie", field:"gsx$prestatie", sorter:"number", formatter:"progress"},
            {title:"Eenheid", field:"gsx$prestatieeenheid", sorter:"string"},
            {title:"Naam", field:"gsx$naam", sorter:"string", align:"left", width:100},
            {title:"Categorie", field:"gsx$categorie", sorter:"string", sortable:true},
            {title:"Datum", field:"gsx$datum", sorter:"date", align:"left"},
            {title:"Plaats", field:"gsx$plaats", align:"right", sorter:"string"},
        ],
        ajaxResponse:function(url, params, response){
            //url - the URL of the request
            //params - the parameters passed with the request
            //response - the JSON object returned in the body of the response.
    
            return response.entry; //return the tableData property of a response json object
        },
    });
    table.setData("https://spreadsheets.google.com/feeds/list/1Ze31_SUFd0ZyqeG1mt1qrEU61onnYhmI9mR1BC1pM7Y/od6/public/values?alt=json");

Unfortunately, I can't figure out what I'm doing wrong. Thanks in advance for any help.

1
I'm getting these same errors too. Did you find a solution? I didn't see the answer below accepted so not sure if you used that and it worked? - Sean

1 Answers

0
votes
    bldgChange: function () {
      console.log(this.selected)
      this.tabulator.parameter = this.selected
      fetch('<API-URL>?Building=' + this.selected)
        .then(response => response.json())
        .then(json => this.tabulator.setData(json.recordset))
    },

I abandoned the ajaxURL as too many people were having issues with it and no real solutions. This is a method I created for what I needed. Maybe you can retrofit it to your needs.