Vuetable-2: Select all checkboxes on page and all checkboxes in table

Created on 16 Nov 2017  路  7Comments  路  Source: ratiw/vuetable-2

Is there a simple way to make a function or there is the function to select all checkboxes on page ( I want to use it on my own button not only with checkbox in TH).
I need also function to select all checkboxes on all pages in table is there a way for this?

All 7 comments

checkboxCheckList () {
    var vuetable = this.$refs.vuetable;
    vuetable.tableData.forEach(function(dataItem) {
        vuetable.selectId(dataItem['id']);
    });
    this.selected = this.$refs.vuetable.selectedTo.length;
},
checkboxUncheckList () {
    var vuetable = this.$refs.vuetable;
    vuetable.tableData.forEach(function(dataItem) {
        vuetable.unselectId(dataItem['id']);
    });
    this.selected = this.$refs.vuetable.selectedTo.length;
}

Is this correct?

@lrembacz that could be an option. You could also directly call the method inside vuetable
http://jsfiddle.net/z11fe07p/2668/

selectAll(value){
     this.$refs.vuetable.toggleAllCheckboxes('__checkbox', {target: {checked: value}})
},

Nice :) And the second part of the question? Is there way to check all checkboxes on every page?

No that is not quite possible. If you use server side pagination then, you only get X items per page displayed and saved in your app. It's not physically possible to check all items if they do not exist yet in your app.

For example, in the fiddle above only 10 items are fetched each time you click on a certain page. Vuetable keeps only those 2 items inside the component which means it doesn't know about the other pages until you click on a page and fetch them

You could for example call the method to select items when the page changes, but that means that you will still have only the items from the current page selected

I would need second query then? Just without pagination? For all of the Ids?

Well that's kind of the whole point of pagination - to not retrieve all the data.
Not sure what's your use case but usually such select-all functionality would affect/select only the items from the current page.

My case is that when Im using filters, Im getting like 200 records. So in pagination i got like 25-100 records per page and now I want to change all status or some other parameter for all 200 records at once (all records I got after filtering).

But I got answers I wannted! Thnaks (y) ! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wa05 picture wa05  路  3Comments

legreco picture legreco  路  5Comments

mix359 picture mix359  路  5Comments

arthurvasconcelos picture arthurvasconcelos  路  3Comments

flyingcoder picture flyingcoder  路  3Comments