-
-
Notifications
You must be signed in to change notification settings - Fork 173
BContainer tag prop, BTable items/rows selection #609
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
Conversation
…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.
|
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">✓</span>
<span class="sr-only">Selected</span>
</template>
<template v-else>
<span aria-hidden="true"> </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
|
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 |
…ossible solution for the issue #375
done. |
|
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 "> 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 |
|
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. |
|
I'm using When I can expect this fix? |
|
Same issue for me on 17.6 as well! |
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