njleonzhang / vue-data-tables

A simple, customizable and pageable table with SSR support, based on vue2 and element-ui

Home Page:https://njleonzhang.github.io/vue-data-tables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to save selection between pages?

moabtools opened this issue · comments

Online reproduce

First table on: https://www.njleonzhang.com/vue-data-tables/#/en-us/event

Expected Behavior

Selected rows do not deselectes when page changes

Current Behavior

Selection losts when page changed

Steps to Reproduce

  1. select some rows in table
  2. go to page 2
  3. return to page 1

Detailed Description

Simply select some rows in your first sample table, then go to page 2, then return to page 1 - voila! - previously selected rows are not selected now. How to save selection between pages?

I think you need store the selected rows by yourself, and leverage el-table apis, such as toggleRowSelection, to implement.

Of course I can do it. But you know, any professional tables implemented this behaviour by default.

currently, it is not supported. I will consider to implement.

I have found a workaround for the moment, you can do this
this.$refs.periodDatatable.$children[0].toggleRowSelection(this.data[1])

Selected the first children of the data-table-server because its a wrapper around el-table from element ui, and with this code this.$refs.periodDatatable.$children[0] you can leverage every native function of the EL TABLE component.

It works but i don't know if its the best solution, the best solution would be to add this function in the datatables component directly !

I have been really busy recently, I am afraid I can not implement this feature in short term. PR is welcomed. 😭

It's ok no problem I will try to implement it myself and then I will a PR, thanks for your libs it has helped me quite a lot this year !!