Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <template>
  2. <v-data-table
  3. :items="items"
  4. :headers="itemHeaders"
  5. :multi-sort="true"
  6. :sort-by="sort"
  7. :sort-desc="true"
  8. >
  9. <template v-slot:header.action>
  10. <slot />
  11. </template>
  12. <template v-slot:item.action="{ item }">
  13. <v-btn icon small @click="$emit('edit', item)">
  14. <v-icon small color="blue darken-2">mdi-pencil</v-icon>
  15. </v-btn>
  16. <v-btn icon small @click="$emit('delete', item)">
  17. <v-icon small color="blue darken-2">mdi-delete</v-icon>
  18. </v-btn>
  19. </template>
  20. </v-data-table>
  21. </template>
  22.  
  23. <script lang="ts">
  24. import Vue from 'vue';
  25.  
  26. export default Vue.extend({
  27. props: {
  28. items: {
  29. type: Array,
  30. required: true,
  31. },
  32. headers: {
  33. type: Array,
  34. required: true,
  35. },
  36. sort: {
  37. type: Array,
  38. required: false,
  39. default: []
  40. }
  41. },
  42. computed: {
  43. itemHeaders(): any[] {
  44. const headers = this.headers.slice();
  45.  
  46. // Always include custom header "Action" for the buttons to be placed in
  47. headers.push({
  48. text: '',
  49. value: 'action',
  50. sortable: false,
  51. });
  52.  
  53. return headers;
  54. },
  55. },
  56. });
  57. </script>
  58.  
  59. <style scoped>
  60.  
  61. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement