@@ -609,6 +609,73 @@ elements are limited. Refer to [MDN](https://developer.mozilla.org/en-US/docs/We
609
609
for details and usage of ` <colgroup> `
610
610
611
611
612
+ ## Table busy state
613
+ ` <b-table> ` provides a ` busy ` prop that will flag the table as busy, which you can
614
+ set to ` true ` just before you update your items, and then set it to ` false ` once you have
615
+ your items. When in hte busy state, the tabe will have the attribute ` aria-busy="true" ` .
616
+
617
+ During the busy state, the table will be rendered in a "muted" look (` opacity: 0.6 ` ), using the
618
+ following custom CSS:
619
+
620
+ ``` css
621
+ /* Busy table styling */
622
+ table .b-table [aria-busy = ' false' ] {
623
+ opacity : 1 ;
624
+ }
625
+ table .b-table [aria-busy = ' true' ] {
626
+ opacity : 0.6 ;
627
+ }
628
+ ```
629
+
630
+ You can override this styling using your own CSS.
631
+
632
+ You may optionally provide a ` table-busy ` slot to show a custom loading message or spinner
633
+ whenever the table's busy state is ` true ` . The slot will be placed in a ` <tr> ` element with
634
+ class ` b-table-busy-slot ` , which has one single ` <td> ` with a ` colspan ` set to the number of fields.
635
+
636
+ ** Example of ` table-busy ` slot usage:**
637
+ ``` html
638
+ <template >
639
+ <div >
640
+ <b-button @click =" toggleBusy" >Toggle Busy State</b-button >
641
+ <b-table :items =" items" :busy =" isBusy" class =" mt-3" outlined >
642
+ <div slot =" table-busy" class =" text-center text-danger" >
643
+ <br ><strong >Loading...</strong ><br ><br >
644
+ </div >
645
+ </b-table >
646
+ </div >
647
+ </template >
648
+ <script >
649
+ export default {
650
+ data () {
651
+ return {
652
+ isBusy: false ,
653
+ items: [
654
+ { first_name: ' Dickerson' , last_name: ' MacDonald' , age: 40 },
655
+ { first_name: ' Larsen' , last_name: ' Shaw' , age: 21 },
656
+ { first_name: ' Geneva' , last_name: ' Wilson' , age: 89 },
657
+ { first_name: ' Jami' , last_name: ' Carney' ,age: 38 }
658
+ ]
659
+ }
660
+ },
661
+ methods: {
662
+ toggleBusy () {
663
+ this .isBusy = ! this .isBusy
664
+ }
665
+ }
666
+ }
667
+ </script >
668
+
669
+ <!-- table-busy-slot.vue -->
670
+ ```
671
+
672
+ Also see the [ ** Using Items Provider Functions** ] ( #using-items-provider-functions ) below for additional
673
+ informaton on the ` busy ` state.
674
+
675
+ ** Note:** All click related and hover events, and sort-changed events will __ not__ be
676
+ emitted when the table is in the ` busy ` state.
677
+
678
+
612
679
## Custom Data Rendering
613
680
Custom rendering for each data field in a row is possible using either
614
681
[ scoped slots] ( http://vuejs.org/v2/guide/components.html#Scoped-Slots )
@@ -1226,22 +1293,23 @@ function myProvider (ctx) {
1226
1293
}
1227
1294
```
1228
1295
1229
- ` <b-table> ` automatically tracks/controls it's ` busy ` state, however it provides
1230
- a ` busy ` prop that can be used either to override inner ` busy ` state, or to monitor
1231
- ` <b-table> ` 's current busy state in your application using the 2-way ` .sync ` modifier.
1296
+ ### Automated table busy state
1297
+ ` <b-table> ` automatically tracks/controls it's ` busy ` state when items provider functions are
1298
+ used, however it also provides a ` busy ` prop that can be used either to override the inner ` busy `
1299
+ state, or to monitor ` <b-table> ` 's current busy state in your application using the 2-way ` .sync ` modifier.
1232
1300
1233
- ** Note:** in order to allow ` <b-table> ` fully track it's ` busy ` state, custom items
1301
+ ** Note:** in order to allow ` <b-table> ` fully track it's ` busy ` state, the custom items
1234
1302
provider function should handle errors from data sources and return an empty
1235
1303
array to ` <b-table> ` .
1236
1304
1237
- ` <b-table> ` provides a ` busy ` prop that will flag the table as busy, which you can
1238
- set to ` true ` just before your async fetch, and then set it to ` false ` once you have
1239
- your data, and just before you send it to the table for display. Example:
1240
-
1305
+ ** Example: usage of busy state**
1241
1306
``` html
1242
- <b-table id =" my-table" :busy.sync =" isBusy" :items =" myProvider" :fields =" fields" ... ></b-table >
1307
+ <b-table id =" my-table"
1308
+ :busy.sync =" isBusy"
1309
+ :items =" myProvider"
1310
+ :fields =" fields" ... >
1311
+ </b-table >
1243
1312
```
1244
-
1245
1313
``` js
1246
1314
data () {
1247
1315
return {
@@ -1250,8 +1318,8 @@ data () {
1250
1318
}
1251
1319
methods: {
1252
1320
myProvider (ctx ) {
1253
- // Here we don't set isBusy prop, so busy state will be handled by table itself
1254
- // this.isBusy = true
1321
+ // Here we don't set isBusy prop, so busy state will be handled by table itself
1322
+ // this.isBusy = true
1255
1323
let promise = axios .get (' /some/url' )
1256
1324
1257
1325
return promise .then ((data ) => {
@@ -1276,6 +1344,7 @@ __not__ be called/refreshed until the `busy` state has been set to `false`.
1276
1344
emitted when in the ` busy ` state (either set automatically during provider update,
1277
1345
or when manually set).
1278
1346
1347
+
1279
1348
### Provider Paging, Filtering, and Sorting
1280
1349
By default, the items provider function is responsible for ** all paging, filtering, and sorting**
1281
1350
of the data, before passing it to ` b-table ` for display.
0 commit comments