@@ -375,10 +375,16 @@ And then using it like this:
375
375
}
376
376
```
377
377
378
- ### Creating Bulk Actions
378
+ ### Bulk Actions
379
379
380
380
Bulk actions are not required, and the bulk actions box, as well as the left-hand checkboxes will be hidden if none are defined.
381
381
382
+ #### The primary key
383
+
384
+ Each row must have a primary key, it's ` 'id' ` by default but you can override it with the ` $primaryKey ` property.
385
+
386
+ #### Defining Bulk Actions
387
+
382
388
To define your bulk actions, you add them to the ** $bulkActions** array.
383
389
384
390
``` php
@@ -404,6 +410,29 @@ public function exportSelected()
404
410
405
411
In the component you have access to ` $this->selectedRowsQuery ` which is a ** Builder** instance of the selected rows.
406
412
413
+ You may also call ` selectedKeys ` which gives you an array of the primary keys in order they were selected:
414
+
415
+ ** Note:** See above to setting the primary key if not ` 'id ` .
416
+
417
+ ``` php
418
+ public function exportSelected()
419
+ {
420
+ if (count($this->selectedKeys)) {
421
+ // Do something with the selected rows
422
+ dd($this->selectedKeys);
423
+
424
+ // => [
425
+ // 1,
426
+ // 2,
427
+ // 3,
428
+ // 4,
429
+ // ]
430
+ }
431
+
432
+ // Notify there is nothing to export
433
+ }
434
+ ```
435
+
407
436
### Options
408
437
409
438
There are some class level properties you can set:
@@ -420,6 +449,7 @@ There are some class level properties you can set:
420
449
| $sortDirectionNames | [ ] | string[ ] | Change the direction name of the column for the sorting pill display (i.e. A-Z, Z-A) |
421
450
| $perPage | 10 | int | The default per page amount selected (must exist in list) |
422
451
| $perPageAccepted | [ 10, 25, 50] | int[ ] | The values for the per page dropdown, in order |
452
+ | $primaryKey | id | string | The column to pluck for bulk actions to populate the ` selectedKeys ` property |
423
453
| $searchFilterDebounce | null | null/int | Adds a debounce of ` $searchFilterDebounce ` ms to the search input |
424
454
| $searchFilterDefer | null | null/bool | Adds ` .defer ` to the search input |
425
455
| $searchFilterLazy | null | null/bool | Adds ` .lazy ` to the search input |
0 commit comments