vue-table-2 with Vuex - not able to change the count property












0















I'm using the vue-table-2 component : https://github.com/matfish2/vue-tables-2 and I'm struggling to make it work as I want.



I have an API (using API Platform) which is already making all the pagination works. So when I fetch for the first time my list of companies it gives the first ten results + the total rows. I store all of this in my vuex store and I am able to display the list in my table (with useVuex false or true so I don't really understand how this parameter works). The issue is I cannot paginate because I only got ten results and can't get the total rows count to change so I do not get the pagination element at the bottom and can't bind something to it to fetch the other pages later.



Since I'm pretty new to VueJs I can't figure out how this should work with my API. Here is my code so far:



My DataTable element :



<v-client-table name="company" :columns="columns" :data="companies" :options="options" :theme="theme" id="dataTable">
<b-button slot="actions" slot-scope="props" variant="secondary" size="sm" class="btn-pill">Edit</b-button>
</v-client-table>


And my script :



<script>
import Vue from 'vue'
import { ClientTable, Event } from 'vue-tables-2'
import { mapGetters } from 'vuex'

Vue.use(ClientTable)

export default {
name: 'DataTable',
components: {
ClientTable,
Event,
},
data: function() {
return {
columns: ['name', 'actions'],
options: {
headings: {
name: 'Name',
actions: 'Actions',
},
sortable: ['name'],
filterable: ['name'],
sortIcon: {
base: 'fa',
up: 'fa-sort-asc',
down: 'fa-sort-desc',
is: 'fa-sort',
},
pagination: {
chunk: 5,
edge: false,
nav: 'scroll',
},
},
useVuex: true,
theme: 'bootstrap4',
template: 'default',
}
},
computed: {
...mapGetters({
companies: 'companyModule/companies',
totalCompanies: 'companyModule/totalCompanies',
}),
},
}
</script>


This is in my component loading the data where I specify how many items per page I want my api to send me and the page I want:



created() {
this.$store.dispatch('companyModule/FETCH_COMPANIES', {
page: 1,
nbItemPerPage: 10,
})
},


My store looks like this:



import ApiService from '@/services/APIService'

export const companyModule = {
strict: true,
namespaced: true,
state: {
companies: ,
totalCompanies: 0,
},
getters: {
companies: state => state.companies,
totalCompanies: state => state.totalCompanies,
},
mutations: {
SET_COMPANIES(state, data) {
state.companies = data.companies
state.totalCompanies = data.totalCompanies
},
},
actions: {
FETCH_COMPANIES(context, payload) {
payload.entity = 'companies'
return ApiService.get(payload).then(data => {
context.commit('SET_COMPANIES', data)
})
},
},
}


When I received my data, I stored everything in my companies state and for now I'm storing everything I'm getting from my API and this looks like this :



{
"@id": "/api/admin/companies/1",
"@type": "Company",
"id": 1,
"name": "Test Company",
}


Thanks in advance for your help !










share|improve this question

























  • how did getting that data from api, please show the code that does that

    – Boussadjra Brahim
    Nov 17 '18 at 13:27











  • At the creation my list view I have :

    – Manapyzz
    Nov 18 '18 at 19:59











  • At the creation my list view I have : created() { this.$store.dispatch('companyModule/FETCH_COMPANIES', { page: 1, nbItemPerPage: 10, }) }, This action fetch API giving me 10 results per page and giving me the the 10 results on page 1. Then I store all my result in my store this is the format of one item stored : { "@id": "/api/admin/companies/1", "@type": "Company", "id": 1, "name": "Test Company" } Hope this helps !

    – Manapyzz
    Nov 18 '18 at 20:05











  • could you edit the question by adding these details to be more clear

    – Boussadjra Brahim
    Nov 18 '18 at 21:46











  • I Just made the edit, sorry I'm not use yet to make posts on Stack Overflow !

    – Manapyzz
    Nov 18 '18 at 22:21
















0















I'm using the vue-table-2 component : https://github.com/matfish2/vue-tables-2 and I'm struggling to make it work as I want.



I have an API (using API Platform) which is already making all the pagination works. So when I fetch for the first time my list of companies it gives the first ten results + the total rows. I store all of this in my vuex store and I am able to display the list in my table (with useVuex false or true so I don't really understand how this parameter works). The issue is I cannot paginate because I only got ten results and can't get the total rows count to change so I do not get the pagination element at the bottom and can't bind something to it to fetch the other pages later.



Since I'm pretty new to VueJs I can't figure out how this should work with my API. Here is my code so far:



My DataTable element :



<v-client-table name="company" :columns="columns" :data="companies" :options="options" :theme="theme" id="dataTable">
<b-button slot="actions" slot-scope="props" variant="secondary" size="sm" class="btn-pill">Edit</b-button>
</v-client-table>


And my script :



<script>
import Vue from 'vue'
import { ClientTable, Event } from 'vue-tables-2'
import { mapGetters } from 'vuex'

Vue.use(ClientTable)

export default {
name: 'DataTable',
components: {
ClientTable,
Event,
},
data: function() {
return {
columns: ['name', 'actions'],
options: {
headings: {
name: 'Name',
actions: 'Actions',
},
sortable: ['name'],
filterable: ['name'],
sortIcon: {
base: 'fa',
up: 'fa-sort-asc',
down: 'fa-sort-desc',
is: 'fa-sort',
},
pagination: {
chunk: 5,
edge: false,
nav: 'scroll',
},
},
useVuex: true,
theme: 'bootstrap4',
template: 'default',
}
},
computed: {
...mapGetters({
companies: 'companyModule/companies',
totalCompanies: 'companyModule/totalCompanies',
}),
},
}
</script>


This is in my component loading the data where I specify how many items per page I want my api to send me and the page I want:



created() {
this.$store.dispatch('companyModule/FETCH_COMPANIES', {
page: 1,
nbItemPerPage: 10,
})
},


My store looks like this:



import ApiService from '@/services/APIService'

export const companyModule = {
strict: true,
namespaced: true,
state: {
companies: ,
totalCompanies: 0,
},
getters: {
companies: state => state.companies,
totalCompanies: state => state.totalCompanies,
},
mutations: {
SET_COMPANIES(state, data) {
state.companies = data.companies
state.totalCompanies = data.totalCompanies
},
},
actions: {
FETCH_COMPANIES(context, payload) {
payload.entity = 'companies'
return ApiService.get(payload).then(data => {
context.commit('SET_COMPANIES', data)
})
},
},
}


When I received my data, I stored everything in my companies state and for now I'm storing everything I'm getting from my API and this looks like this :



{
"@id": "/api/admin/companies/1",
"@type": "Company",
"id": 1,
"name": "Test Company",
}


Thanks in advance for your help !










share|improve this question

























  • how did getting that data from api, please show the code that does that

    – Boussadjra Brahim
    Nov 17 '18 at 13:27











  • At the creation my list view I have :

    – Manapyzz
    Nov 18 '18 at 19:59











  • At the creation my list view I have : created() { this.$store.dispatch('companyModule/FETCH_COMPANIES', { page: 1, nbItemPerPage: 10, }) }, This action fetch API giving me 10 results per page and giving me the the 10 results on page 1. Then I store all my result in my store this is the format of one item stored : { "@id": "/api/admin/companies/1", "@type": "Company", "id": 1, "name": "Test Company" } Hope this helps !

    – Manapyzz
    Nov 18 '18 at 20:05











  • could you edit the question by adding these details to be more clear

    – Boussadjra Brahim
    Nov 18 '18 at 21:46











  • I Just made the edit, sorry I'm not use yet to make posts on Stack Overflow !

    – Manapyzz
    Nov 18 '18 at 22:21














0












0








0








I'm using the vue-table-2 component : https://github.com/matfish2/vue-tables-2 and I'm struggling to make it work as I want.



I have an API (using API Platform) which is already making all the pagination works. So when I fetch for the first time my list of companies it gives the first ten results + the total rows. I store all of this in my vuex store and I am able to display the list in my table (with useVuex false or true so I don't really understand how this parameter works). The issue is I cannot paginate because I only got ten results and can't get the total rows count to change so I do not get the pagination element at the bottom and can't bind something to it to fetch the other pages later.



Since I'm pretty new to VueJs I can't figure out how this should work with my API. Here is my code so far:



My DataTable element :



<v-client-table name="company" :columns="columns" :data="companies" :options="options" :theme="theme" id="dataTable">
<b-button slot="actions" slot-scope="props" variant="secondary" size="sm" class="btn-pill">Edit</b-button>
</v-client-table>


And my script :



<script>
import Vue from 'vue'
import { ClientTable, Event } from 'vue-tables-2'
import { mapGetters } from 'vuex'

Vue.use(ClientTable)

export default {
name: 'DataTable',
components: {
ClientTable,
Event,
},
data: function() {
return {
columns: ['name', 'actions'],
options: {
headings: {
name: 'Name',
actions: 'Actions',
},
sortable: ['name'],
filterable: ['name'],
sortIcon: {
base: 'fa',
up: 'fa-sort-asc',
down: 'fa-sort-desc',
is: 'fa-sort',
},
pagination: {
chunk: 5,
edge: false,
nav: 'scroll',
},
},
useVuex: true,
theme: 'bootstrap4',
template: 'default',
}
},
computed: {
...mapGetters({
companies: 'companyModule/companies',
totalCompanies: 'companyModule/totalCompanies',
}),
},
}
</script>


This is in my component loading the data where I specify how many items per page I want my api to send me and the page I want:



created() {
this.$store.dispatch('companyModule/FETCH_COMPANIES', {
page: 1,
nbItemPerPage: 10,
})
},


My store looks like this:



import ApiService from '@/services/APIService'

export const companyModule = {
strict: true,
namespaced: true,
state: {
companies: ,
totalCompanies: 0,
},
getters: {
companies: state => state.companies,
totalCompanies: state => state.totalCompanies,
},
mutations: {
SET_COMPANIES(state, data) {
state.companies = data.companies
state.totalCompanies = data.totalCompanies
},
},
actions: {
FETCH_COMPANIES(context, payload) {
payload.entity = 'companies'
return ApiService.get(payload).then(data => {
context.commit('SET_COMPANIES', data)
})
},
},
}


When I received my data, I stored everything in my companies state and for now I'm storing everything I'm getting from my API and this looks like this :



{
"@id": "/api/admin/companies/1",
"@type": "Company",
"id": 1,
"name": "Test Company",
}


Thanks in advance for your help !










share|improve this question
















I'm using the vue-table-2 component : https://github.com/matfish2/vue-tables-2 and I'm struggling to make it work as I want.



I have an API (using API Platform) which is already making all the pagination works. So when I fetch for the first time my list of companies it gives the first ten results + the total rows. I store all of this in my vuex store and I am able to display the list in my table (with useVuex false or true so I don't really understand how this parameter works). The issue is I cannot paginate because I only got ten results and can't get the total rows count to change so I do not get the pagination element at the bottom and can't bind something to it to fetch the other pages later.



Since I'm pretty new to VueJs I can't figure out how this should work with my API. Here is my code so far:



My DataTable element :



<v-client-table name="company" :columns="columns" :data="companies" :options="options" :theme="theme" id="dataTable">
<b-button slot="actions" slot-scope="props" variant="secondary" size="sm" class="btn-pill">Edit</b-button>
</v-client-table>


And my script :



<script>
import Vue from 'vue'
import { ClientTable, Event } from 'vue-tables-2'
import { mapGetters } from 'vuex'

Vue.use(ClientTable)

export default {
name: 'DataTable',
components: {
ClientTable,
Event,
},
data: function() {
return {
columns: ['name', 'actions'],
options: {
headings: {
name: 'Name',
actions: 'Actions',
},
sortable: ['name'],
filterable: ['name'],
sortIcon: {
base: 'fa',
up: 'fa-sort-asc',
down: 'fa-sort-desc',
is: 'fa-sort',
},
pagination: {
chunk: 5,
edge: false,
nav: 'scroll',
},
},
useVuex: true,
theme: 'bootstrap4',
template: 'default',
}
},
computed: {
...mapGetters({
companies: 'companyModule/companies',
totalCompanies: 'companyModule/totalCompanies',
}),
},
}
</script>


This is in my component loading the data where I specify how many items per page I want my api to send me and the page I want:



created() {
this.$store.dispatch('companyModule/FETCH_COMPANIES', {
page: 1,
nbItemPerPage: 10,
})
},


My store looks like this:



import ApiService from '@/services/APIService'

export const companyModule = {
strict: true,
namespaced: true,
state: {
companies: ,
totalCompanies: 0,
},
getters: {
companies: state => state.companies,
totalCompanies: state => state.totalCompanies,
},
mutations: {
SET_COMPANIES(state, data) {
state.companies = data.companies
state.totalCompanies = data.totalCompanies
},
},
actions: {
FETCH_COMPANIES(context, payload) {
payload.entity = 'companies'
return ApiService.get(payload).then(data => {
context.commit('SET_COMPANIES', data)
})
},
},
}


When I received my data, I stored everything in my companies state and for now I'm storing everything I'm getting from my API and this looks like this :



{
"@id": "/api/admin/companies/1",
"@type": "Company",
"id": 1,
"name": "Test Company",
}


Thanks in advance for your help !







vue.js vuejs2 vue-component vuex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 22:26







Manapyzz

















asked Nov 17 '18 at 12:27









ManapyzzManapyzz

111




111













  • how did getting that data from api, please show the code that does that

    – Boussadjra Brahim
    Nov 17 '18 at 13:27











  • At the creation my list view I have :

    – Manapyzz
    Nov 18 '18 at 19:59











  • At the creation my list view I have : created() { this.$store.dispatch('companyModule/FETCH_COMPANIES', { page: 1, nbItemPerPage: 10, }) }, This action fetch API giving me 10 results per page and giving me the the 10 results on page 1. Then I store all my result in my store this is the format of one item stored : { "@id": "/api/admin/companies/1", "@type": "Company", "id": 1, "name": "Test Company" } Hope this helps !

    – Manapyzz
    Nov 18 '18 at 20:05











  • could you edit the question by adding these details to be more clear

    – Boussadjra Brahim
    Nov 18 '18 at 21:46











  • I Just made the edit, sorry I'm not use yet to make posts on Stack Overflow !

    – Manapyzz
    Nov 18 '18 at 22:21



















  • how did getting that data from api, please show the code that does that

    – Boussadjra Brahim
    Nov 17 '18 at 13:27











  • At the creation my list view I have :

    – Manapyzz
    Nov 18 '18 at 19:59











  • At the creation my list view I have : created() { this.$store.dispatch('companyModule/FETCH_COMPANIES', { page: 1, nbItemPerPage: 10, }) }, This action fetch API giving me 10 results per page and giving me the the 10 results on page 1. Then I store all my result in my store this is the format of one item stored : { "@id": "/api/admin/companies/1", "@type": "Company", "id": 1, "name": "Test Company" } Hope this helps !

    – Manapyzz
    Nov 18 '18 at 20:05











  • could you edit the question by adding these details to be more clear

    – Boussadjra Brahim
    Nov 18 '18 at 21:46











  • I Just made the edit, sorry I'm not use yet to make posts on Stack Overflow !

    – Manapyzz
    Nov 18 '18 at 22:21

















how did getting that data from api, please show the code that does that

– Boussadjra Brahim
Nov 17 '18 at 13:27





how did getting that data from api, please show the code that does that

– Boussadjra Brahim
Nov 17 '18 at 13:27













At the creation my list view I have :

– Manapyzz
Nov 18 '18 at 19:59





At the creation my list view I have :

– Manapyzz
Nov 18 '18 at 19:59













At the creation my list view I have : created() { this.$store.dispatch('companyModule/FETCH_COMPANIES', { page: 1, nbItemPerPage: 10, }) }, This action fetch API giving me 10 results per page and giving me the the 10 results on page 1. Then I store all my result in my store this is the format of one item stored : { "@id": "/api/admin/companies/1", "@type": "Company", "id": 1, "name": "Test Company" } Hope this helps !

– Manapyzz
Nov 18 '18 at 20:05





At the creation my list view I have : created() { this.$store.dispatch('companyModule/FETCH_COMPANIES', { page: 1, nbItemPerPage: 10, }) }, This action fetch API giving me 10 results per page and giving me the the 10 results on page 1. Then I store all my result in my store this is the format of one item stored : { "@id": "/api/admin/companies/1", "@type": "Company", "id": 1, "name": "Test Company" } Hope this helps !

– Manapyzz
Nov 18 '18 at 20:05













could you edit the question by adding these details to be more clear

– Boussadjra Brahim
Nov 18 '18 at 21:46





could you edit the question by adding these details to be more clear

– Boussadjra Brahim
Nov 18 '18 at 21:46













I Just made the edit, sorry I'm not use yet to make posts on Stack Overflow !

– Manapyzz
Nov 18 '18 at 22:21





I Just made the edit, sorry I'm not use yet to make posts on Stack Overflow !

– Manapyzz
Nov 18 '18 at 22:21












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53351260%2fvue-table-2-with-vuex-not-able-to-change-the-count-property%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53351260%2fvue-table-2-with-vuex-not-able-to-change-the-count-property%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings