Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-select rows #60

Open
angelofenoglio opened this issue Jul 2, 2019 · 2 comments
Open

Pre-select rows #60

angelofenoglio opened this issue Jul 2, 2019 · 2 comments

Comments

@angelofenoglio
Copy link

It would be nice to be able to not only give the rows information to the table, but also give the already selected rows, to avoid losing that information on a page reload.

Maybe as a new prop, passing only the indexes of the previously selected rows or something like that.

@Kwaadpepper
Copy link

Found a workaround, #82 (comment)

@kalakeli
Copy link

kalakeli commented Apr 8, 2021

I also needed something to dynamically set a selection of rows checked. Searched for hours, tried many things, here is what I came up with following the idea of @Kwaadpepper

  1. give a ref attribute to your table so you can refer to it by using this.$refs.vbt (if vbt is your ref)
  2. get and set the rows array as usual
  3. then map over the rows and add the appropriate row to the list of selected_items . Your reference needs to have vbt_id so make sure you have a counter running. In my data I have isSelected set to 1 if it is part of the selection.
   let i = 1, self = this;
   self.rows.map( (item) => { 
      if (item.isSelected==1) {
          item.vbt_id = i++;
          self.$refs.vbt.addSelectedItem(item);
      } else {
          item.vbt_id = i++;
      }
 });

For me that was all I needed to see my selection properly checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants