My attempt was trying to sort the outcome of the data in the method, but later I want to implement a button in the table header, but I can't even get the sorting part of a, b solution to work with the data from rows = []. I can use the vuetify table but I want to learn how I can do it manually...
in simple words, I want to sort by this row array Amount_Raised_Millions
<template>
<div class="container-fluid">
<div class="row mb-10">
<main role="main" class="col-md-12 ml-sm-auto col-lg-12 pt-3 px-4">
<div class=" pb-2 ma-3 ">
<h2 class="center">Funding</h2>
<v-divider></v-divider>
</div>
<div class=" table-responsive">
<table class="table table-striped mb-0">
<thead>
<tr>
<th>Name</th>
<th>Funding Date</th>
<th>Amount Raised</th>
<th>Round</th>
<th>Total Raised</th>
<th>Founder</th>
<th>Est.</th>
<th>Location</th>
<th>Lead Investor</th>
<th class="d-none">Employees</th>
</tr>
</thead>
<span class="table-span">
<v-row class="center mt-15" v-if="loading">
<v-col
cols="12"
>
<v-progress-circular
:size="150"
color="blue"
indeterminate
> Loading...
</v-progress-circular>
</v-col>
</v-row>
<tbody >
<Row v-bind:key="row.id" v-for="row in rows" v-bind:row="row" />
</tbody>
</span>
</table>
</div>
</main>
</div>
</div>
</template>
<script>
import Row from '@/components/Row.vue';
const { GoogleSpreadsheet } = require('google-spreadsheet');
const creds = require('@/client_secret.json');
export default {
name: "Sheet",
components: {
Row
},
props: ["sheet"],
data() {
return {
rows: [],
loading: true,
}
},
methods:{
async accessSpreadSheet() {
const doc = new GoogleSpreadsheet(process.env.VUE_APP_API_KEY);
await doc.useServiceAccountAuth(creds);
await doc.loadInfo();
const sheet = doc.sheetsByIndex[0];
const rows = await sheet.getRows({
offset: 1
})
this.rows = rows.sort((a,b)=>a.Name-b.Name);
this.loading = false;
//console.log(rows)
}
},
created() {
this.accessSpreadSheet();
// testing console.log(process.env.VUE_APP_API_KEY)
},
//computed() {
//return this.rows.sort((a,b)=>a.row.Name-b.row.Name);
//}
}
</script>