|
77 | 77 | </tr> |
78 | 78 | </thead> |
79 | 79 | <tbody> |
80 | | - <tr |
81 | | - v-for="row in rows" |
82 | | - :key="'row-' + row.id" |
83 | | - class="data-table__table-row" |
| 80 | + <slot |
| 81 | + name="rows" |
| 82 | + :rows="rows" |
| 83 | + :columns="columns" |
| 84 | + :update-row="updateRow" |
| 85 | + :delete-row="deleteRow" |
| 86 | + :refresh="refresh" |
84 | 87 | > |
85 | | - <td |
86 | | - v-for="col in columns" |
87 | | - :key="'col-' + col.key" |
88 | | - class="data-table__table-cell" |
89 | | - :class="{ |
90 | | - 'data-table__table-cell--sticky-left': col.stickyLeft, |
91 | | - 'data-table__table-cell--sticky-right': col.stickyRight, |
92 | | - [`data-table__table-cell--${col.key}`]: true, |
93 | | - }" |
94 | | - @contextmenu="$emit('row-context', { col, row, event: $event })" |
| 88 | + <tr |
| 89 | + v-for="row in rows" |
| 90 | + :key="'row-' + row.id" |
| 91 | + class="data-table__table-row" |
95 | 92 | > |
96 | | - <div class="data-table__table-cell-content"> |
97 | | - <component |
98 | | - :is="col.cellComponent" |
99 | | - :row="row" |
100 | | - :column="col" |
101 | | - v-on="$attrs" |
102 | | - @row-context="(payload) => $emit('row-context', payload)" |
103 | | - @row-update="updateRow" |
104 | | - @row-delete="deleteRow" |
105 | | - @refresh="refresh" |
106 | | - /> |
107 | | - </div> |
108 | | - </td> |
109 | | - </tr> |
| 93 | + <td |
| 94 | + v-for="col in columns" |
| 95 | + :key="'col-' + col.key" |
| 96 | + class="data-table__table-cell" |
| 97 | + :class="{ |
| 98 | + 'data-table__table-cell--sticky-left': col.stickyLeft, |
| 99 | + 'data-table__table-cell--sticky-right': col.stickyRight, |
| 100 | + [`data-table__table-cell--${col.key}`]: true, |
| 101 | + }" |
| 102 | + @contextmenu=" |
| 103 | + $emit('row-context', { col, row, event: $event }) |
| 104 | + " |
| 105 | + > |
| 106 | + <div class="data-table__table-cell-content"> |
| 107 | + <component |
| 108 | + :is="col.cellComponent" |
| 109 | + :row="row" |
| 110 | + :column="col" |
| 111 | + v-on="$attrs" |
| 112 | + @row-context="(payload) => $emit('row-context', payload)" |
| 113 | + @row-update="updateRow" |
| 114 | + @row-delete="deleteRow" |
| 115 | + @refresh="refresh" |
| 116 | + /> |
| 117 | + </div> |
| 118 | + </td> |
| 119 | + </tr> |
| 120 | + </slot> |
110 | 121 | </tbody> |
111 | 122 | </table> |
112 | 123 | </div> |
@@ -145,6 +156,7 @@ import isObject from 'lodash/isObject' |
145 | 156 | * Two slot props are provided `updateRow` and `deleteRow` which are functions |
146 | 157 | * called when your menu has changed the row state which trigger the CrudTable |
147 | 158 | * to rerender the rows with the new data. |
| 159 | + * #rows: Can optionally replace the rows in the table. |
148 | 160 | */ |
149 | 161 | export default { |
150 | 162 | name: 'CrudTable', |
|
0 commit comments