Skip to content

Commit

Permalink
Fixed #850 - state-save and state-restore events for Table
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Jan 20, 2021
1 parent b200e9e commit 1937999
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/datatable/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default {
emits: ['update:first', 'update:rows', 'page', 'update:sortField', 'update:sortOrder', 'update:multiSortMeta', 'sort', 'filter', 'row-click',
'update:selection', 'row-select', 'row-unselect', 'update:contextMenuSelection', 'row-contextmenu', 'row-unselect-all', 'row-select-all',
'column-resize-end', 'column-reorder', 'row-reorder', 'update:expandedRows', 'row-collapse', 'row-expand',
'update:expandedRowGroups', 'rowgroup-collapse', 'rowgroup-expand', 'update:filters', 'virtual-scroll',
'update:expandedRowGroups', 'rowgroup-collapse', 'rowgroup-expand', 'update:filters', 'virtual-scroll', 'state-restore', 'state-save',
'cell-edit-init', 'cell-edit-complete', 'cell-edit-cancel', 'update:editingRows', 'row-edit-init', 'row-edit-save', 'row-edit-cancel'],
props: {
value: {
Expand Down Expand Up @@ -1488,6 +1488,8 @@ export default {
if (Object.keys(state).length) {
storage.setItem(this.stateKey, JSON.stringify(state));
}
this.$emit('state-save', state);
},
restoreState() {
const storage = this.getStorage();
Expand Down Expand Up @@ -1536,6 +1538,8 @@ export default {
this.d_selectionKeys = restoredState.d_selectionKeys;
this.$emit('update:selection', restoredState.selection);
}
this.$emit('state-restore', restoredState);
}
},
saveColumnWidths(state) {
Expand Down
36 changes: 36 additions & 0 deletions src/views/datatable/DataTableDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2345,6 +2345,42 @@ export default {
event.rows: Rows per page.</td>
<td>Callback to invoke during virtual scrolling.</td>
</tr>
<tr>
<td>state-save</td>
<td>event.first: Index of first record <br/>
event.rows: Number of rows to display in new page <br/>
event.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <br />
event.columWidths: Comma separated list of column widths <br />
event.columnOrder: Order of the columns <br />
event.expandedRows: Instances of rows in expanded state <br />
event.expandedRowKeys: Keys of rows in expanded state <br />
event.expandedRowGroups: Instances of row groups in expanded state <br />
event.selection: Selected rows <br />
event.selectionKeys: Keys of selected rows <br />
</td>
<td>Invoked when a stateful table saves the state.</td>
</tr>
<tr>
<td>state-restore</td>
<td>event.first: Index of first record <br/>
event.rows: Number of rows to display in new page <br/>
event.sortField: Field to sort against <br />
event.sortOrder: Sort order as integer <br />
event.multiSortMeta: MultiSort metadata <br />
event.filters: Collection of active filters <br />
event.columWidths: Comma separated list of column widths <br />
event.columnOrder: Order of the columns <br />
event.expandedRows: Instances of rows in expanded state <br />
event.expandedRowKeys: Keys of rows in expanded state <br />
event.expandedRowGroups: Instances of row groups in expanded state <br />
event.selection: Selected rows <br />
event.selectionKeys: Keys of selected rows <br />
</td>
<td>Invoked when a stateful table restores the state.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 1937999

Please sign in to comment.