Skip to content

Commit

Permalink
Add cell editing
Browse files Browse the repository at this point in the history
  • Loading branch information
radupasparuga committed Oct 2, 2020
1 parent a7bc53a commit b3a3c9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/compounds/Table/DataGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class DataGrid {
this.originalRows.splice(index, 1)
}

editCell(row, column, newValue) {
row[column.name] = newValue
}

sortByColumn(column: string, ascendant: boolean) {
this.rows.sort((a, b) => {
if(a[column] < b[column]) { return ascendant ? -1 : 1 };
Expand Down
7 changes: 6 additions & 1 deletion src/components/compounds/Table/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Table = {
sortable: Boolean,
expandable: Boolean,
draggable: Boolean,
editable: Boolean
},
setup(props, { emit }) {
Expand Down Expand Up @@ -203,7 +204,11 @@ export default Table
}}</v-tag></a
>
</td>
<td v-for="column in data.getColumns()" :key="column.name" :class="column.style">
<td
v-for="column in data.getColumns()"
:key="column.name" :class="column.style"
:contenteditable='props.editable'
v-on:blur="data.editCell(row, column, $event.target.textContent)">
<slot :name="column.name" :row="row">
{{ row[column.name] }}
</slot>
Expand Down

0 comments on commit b3a3c9f

Please sign in to comment.