vue-bootstrap4-table icon indicating copy to clipboard operation
vue-bootstrap4-table copied to clipboard

Pre-select rows

Open angelofenoglio opened this issue 5 years ago • 2 comments

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.

angelofenoglio avatar Jul 02 '19 14:07 angelofenoglio

Found a workaround, https://github.com/rubanraj54/vue-bootstrap4-table/issues/82#issuecomment-707314414

Kwaadpepper avatar Oct 12 '20 20:10 Kwaadpepper

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.

kalakeli avatar Apr 08 '21 13:04 kalakeli