Skip to content

Conversation

@devhus
Copy link
Contributor

@devhus devhus commented Aug 30, 2022

BREAKING CHANGES: .container & .container-fluid CSS classes now have a default 'block' display to behave as a 'div' element when the BContainer tag is changed
BREAKING CHANGE: BTable 'sorted' event output value was changed to an object with keys [sort(string), desc(boolean)] for better ts type support.
BREAKING CHANGES: BTable sortInternal prop default value is now 'false'

fix: added a few missing props to the BTable.d.ts file
fix: replaced BTable emits definition array with a typescript interface for better type support
fix: update the data type of a few of BTable props

feat: Added 'tag' prop to BContainer component
feat: Added BTable selectable prop that adds the selection functionality to the table
feat: Added BTable select-mode prop with a value of [multi, single, range] to expand how the table selection can be used.
feat: Added Btable select-head prop to show an extra Head & Cell to the table
feat: Added selectHead & selectCell slots to customize the selection of the extra head & cells.
feat: BTable selection-variant prop was added, giving the ability to use bootstrap's colors as bg to the selected rows

devhus added 3 commits August 30, 2022 19:37
…fault 'block' display to behave as a 'div' element when the BContainer tag is changed
fix: replaced BTable emits definition array with a typescript interface for better type support
BREAKING CHANGE: The  event output value was changed to an object with 'sort[string]' and 'desc[boolean]' for better ts type support.
feat: Added BTable selectable prop that adds the selection functionality to the table, Added select-mode prop with value of [multi, single, range] to expend the table selection can be used with.
feat: Added Btable select-head prop to show an extra Head & Cell to the table, Added selectHead & selectCell slots to customize the selection extra head & cells.
@devhus
Copy link
Contributor Author

devhus commented Aug 30, 2022

A working example:

<template>
  <b-container class="py-4">
    <b-form-group
      label="Selection mode:"
      label-for="table-select-mode-select"
      label-cols-md="4"
    >
      <b-form-select
        id="table-select-mode-select"
        v-model="selectMode"
        :options="modes"
        class="mb-3"
      ></b-form-select>
    </b-form-group>

    <b-table
      :items="items"
      :fields="fields"
      :select-mode="selectMode"
      responsive="sm"
      ref="selectableTable"
      selectable
      @row-selected="onRowSelected"
      @row-unselected="onRowUnSelected"
      @selection="onSelection"
      :select-cell="false"
    >
      <template #selectHead>Is Selected?</template>
      <template #selectCell>✔</template>
      <!-- Example scoped slot for select state illustrative purposes -->
      <template #cell(selected)="{ rowSelected }">
        <template v-if="rowSelected">
          <span aria-hidden="true">&check;</span>
          <span class="sr-only">Selected</span>
        </template>
        <template v-else>
          <span aria-hidden="true">&nbsp;</span>
          <span class="sr-only">Not selected</span>
        </template>
      </template>
    </b-table>
    <p>
      Selected Rows:<br>
      {{ selected }}
    </p>
    <p>
      Internal Selected Rows:<br>
      {{ internalSelected }}
    </p>
  </b-container>
</template>

<script  lang="ts" >
import { defineComponent } from "vue";
import { BTableProps } from "./types/components";

export default defineComponent({
  data() {
    return {
      modes: ['multi', 'single', 'range'],
      fields: ['isActive', 'age', 'first_name', 'last_name'],
      items: [
        { isActive: true, age: 40, first_name: 'Dickerson', last_name: 'Macdonald' },
        { isActive: false, age: 21, first_name: 'Larsen', last_name: 'Shaw' },
        { isActive: false, age: 89, first_name: 'Geneva', last_name: 'Wilson' },
        { isActive: true, age: 38, first_name: 'Jami', last_name: 'Carney' }
      ],
      selectMode: 'multi' as BTableProps['selectMode'],
      selected: [],
      internalSelected: [],
    }
  },
  methods: {
    onRowSelected(item: any) {
      this.selected.push(item);
    },
    onRowUnSelected(item: any) {
      this.selected.splice(this.selected.indexOf(item), 1);
    },
    onSelection(items: any) {
      this.internalSelected = items;
    },
  }
});
</script>

More logic to be added later to give the ability to update selectedItems array through props using v-model, and provide few methods to control the internal selectedItems array (such as, selectAllRows, clearSelected, selectRow(index))

…se bootstrap's colors as bg to the selected rows
@VividLemon
Copy link
Member

If you could possibly address #608. Feel free to give them a message, figure out a solution, or copy both the changes together, as to not have any merge conflicts. @cattaneoinfoesse

@devhus
Copy link
Contributor Author

devhus commented Aug 31, 2022

If you could possibly address #608. Feel free to give them a message, figure out a solution, or copy both the changes together, as to not have any merge conflicts. @cattaneoinfoesse

done.

@devhus devhus requested a review from VividLemon August 31, 2022 01:50
@VividLemon VividLemon merged commit ed5c0cd into bootstrap-vue-next:main Aug 31, 2022
@devhus devhus mentioned this pull request Sep 8, 2022
@ahmedrazaa
Copy link

seems working fine for me except to know one thing, how i can change icon for not selected item it always show ✔ for all rows.<template v-slot:cell(selected)="rowSelected ">

      <template v-if="rowSelected">
      <span aria-hidden="true">&check;</span>
      <span class="sr-only">Selected</span>
    </template>
    <template v-else>
      <span aria-hidden="true">&nbsp;</span>
      <span class="sr-only">Not selected</span>
    </template> 
   </template> 

it looks like that part of code isn't working, always show ✔ for all rows

@devhus
Copy link
Contributor Author

devhus commented Sep 12, 2022

seems working fine for me except to know one thing, how i can change icon for not selected item it always show ✔ for all rows.<template v-slot:cell(selected)="rowSelected ">

      <template v-if="rowSelected">
      <span aria-hidden="true">&check;</span>
      <span class="sr-only">Selected</span>
    </template>
    <template v-else>
      <span aria-hidden="true">&nbsp;</span>
      <span class="sr-only">Not selected</span>
    </template> 
   </template> 

it looks like that part of code isn't working, always show ✔ for all rows

with the upcoming release update, it will be customizable using CSS. Please take a look at #643

@VividLemon
Copy link
Member

I think it would be nice if additionally those values could be modified using slots, for those like me that don't like touching css.

@devhus devhus mentioned this pull request Sep 12, 2022
@yashwp
Copy link

yashwp commented Mar 7, 2024

I'm using 0.16.6 version of this package. But I cannot use rowSelected to render checkboxes for each row and select/deselect on row selection.

When I can expect this fix?

<b-table responsive hover :items="items" :fields="columns" tbody-tr-class="cursor-pointer"
               selectable select-mode="multi" @row-selected="onRowSelect" :select-head="true"
               @row-unselected="onRowDeselect">
        <template #cell(null)="{ rowSelected }">
          {{ rowSelected }}
          <input type="checkbox" :checked="rowSelected">
        </template>
      </b-table>
      ```

@noque-lind
Copy link

Same issue for me on 17.6 as well!

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

Successfully merging this pull request may close these issues.

5 participants