File tree Expand file tree Collapse file tree 6 files changed +42
-3
lines changed Expand file tree Collapse file tree 6 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ module.exports = {
1010 ] ,
1111 "vue/html-indent" : 0 ,
1212 "vue/max-attributes-per-line" : 0 ,
13+ "vue/html-self-closing" : 0 ,
1314 }
1415}
Original file line number Diff line number Diff line change @@ -30,8 +30,11 @@ import { TVTable } from '@bitthecat/tailwind-vue-data-table'
3030
3131<img src =" https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/assets/tvpagination.jpg " />
3232
33- - Select row column (with checkbox)
33+ - Select row column (with checkbox) ✔️
34+
35+ <img src =" https://github.com/BitTheCat/tailwind-vue-data-table/blob/main/assets/tvtable_checkbox.jpg " />
3436- Row detail
37+ - Row Clicked event
3538- ...
3639<hr >
3740
@@ -45,6 +48,7 @@ import { TVTable } from '@bitthecat/tailwind-vue-data-table'
4548| perPage | 15 | number of rows displayed for page (used by the paginator) |
4649| hidePagination | false | enables for hide paginator |
4750| multipleSortable | false | enables multiple sortable for table header |
51+ | enableCheck | false | enables checkbox for table row |
4852
4953### Slots
5054
@@ -79,6 +83,7 @@ data retrieves the field value
7983| --- | --- |
8084| updateSortable | emit the sortable field/fields |
8185| changePage | emit the page change |
86+ | checkRow | emit the row item |
8287
8388<hr >
8489
Original file line number Diff line number Diff line change 1717 multiple-sortable
1818 :total-rows =" items.length"
1919 :per-page =" perPage"
20+ enable-check
2021 @change-page =" changePage"
22+ @check-row =" checkRow"
2123 >
2224 <template #cell :username =" { item } " >
2325 {{ item.emoji }} - {{ item.username }}
2426 </template >
2527 </TVTable >
28+ Selected:
29+ <pre >
30+ {{ selectRow }}
31+ </pre >
2632 </div >
2733 </div >
2834</template >
@@ -106,4 +112,15 @@ const changePage = (values) => {
106112 filterItems .value = items .value .slice (values .from , values .to )
107113}
108114
115+ const selectRow = ref ([])
116+ const checkRow = (value ) => {
117+ console .log (selectRow .value .includes (value))
118+ if (selectRow .value .includes (value)) {
119+ let index = selectRow .value .indexOf (value)
120+ selectRow .value .splice (index, 1 )
121+ } else {
122+ selectRow .value .push (value)
123+ }
124+ }
125+
109126 </script >
Original file line number Diff line number Diff line change 11{
22 "name" : " @bitthecat/tailwind-vue-data-table" ,
3- "version" : " 0.1.2 " ,
3+ "version" : " 0.1.3 " ,
44 "keywords" : [
55 " tailwindcss" ,
66 " vue" ,
Original file line number Diff line number Diff line change 66 <table class =" min-w-full" >
77 <thead class =" bg-gray-300 border" >
88 <tr class =" divide-x divide-y" >
9+ <th
10+ v-if =" enableCheck"
11+ class =" px-2 py-1.5"
12+ style =" width : 30px "
13+ />
14+
915 <th
1016 v-for =" field in fields"
1117 :key =" field.label"
5157 :key =" item.label"
5258 class =" divide-x divide-y last:border-b-0 px-2 py-1.5 text-left text-xs font-medium border odd:bg-gray-300/50 even:bg-gray-100/50 hover:bg-gray-400/50"
5359 >
60+ <td
61+ v-if =" enableCheck"
62+ :key =" `check_${item.label}`"
63+ class =" px-2 py-1.5 align-top lg:table-cell last:border-b-0"
64+ >
65+ <input id =" checkbox" v-model =" selectedRow" :value =" item" type =" checkbox" @change =" emit('checkRow', item)" />
66+ </td >
67+
5468 <td
5569 v-for =" field in fields"
5670 :key =" field.key"
@@ -105,9 +119,10 @@ const props = defineProps({
105119 },
106120 hidePagination: Boolean ,
107121 multipleSortable: Boolean ,
122+ enableCheck: Boolean ,
108123})
109124
110- const emit = defineEmits ([' updateSortable' , ' changePage' ])
125+ const emit = defineEmits ([' updateSortable' , ' changePage' , ' checkRow ' ])
111126
112127const localTotalRows = ref (props .totalRows || props .items .length || 0 )
113128const fromRow = ref (0 )
@@ -119,6 +134,7 @@ const getField = (item, field) => {
119134}
120135
121136const sortable = ref ({})
137+ const selectedRow = ref ([])
122138
123139const updateSortable = (key , sort ) => {
124140 props .multipleSortable
You can’t perform that action at this time.
0 commit comments