From fe9f51d903e07b7d1f5dd9fdccbf75e01d778df8 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Sat, 18 Apr 2020 21:41:45 +0300 Subject: [PATCH] Fixed #282 - TreeTable should pass more information on page-sort-filter events --- src/components/treetable/TreeTable.vue | 42 +++++++++++++++++++------- src/views/treetable/TreeTableDoc.vue | 41 ++++++++++++++++++------- 2 files changed, 61 insertions(+), 22 deletions(-) diff --git a/src/components/treetable/TreeTable.vue b/src/components/treetable/TreeTable.vue index 5b6d47ab6..6d34a84d2 100644 --- a/src/components/treetable/TreeTable.vue +++ b/src/components/treetable/TreeTable.vue @@ -354,9 +354,13 @@ export default { this.d_first = event.first; this.d_rows = event.rows; + let pageEvent = this.createLazyLoadEvent(event); + pageEvent.pageCount = event.pageCount; + pageEvent.page = event.page; + this.$emit('update:first', this.d_first); this.$emit('update:rows', this.d_rows); - this.$emit('page', event); + this.$emit('page', pageEvent); }, resetPage() { this.d_first = 0; @@ -457,12 +461,7 @@ export default { this.$emit('update:multiSortMeta', this.d_multiSortMeta); } - this.$emit('sort', { - originalEvent: event, - sortField: this.d_sortField, - sortOrder: this.d_sortOrder, - multiSortMeta: this.d_multiSortMeta - }); + this.$emit('sort', this.createLazyLoadEvent(event)); } } }, @@ -602,10 +601,9 @@ export default { valueChanged = valueChanged || !localMatch || globalMatch; } - this.$emit('filter', { - filters: this.filters, - filteredValue: filteredNodes - }); + let filterEvent = this.createLazyLoadEvent(event); + filterEvent.filteredValue = filteredNodes; + this.$emit('filter', filterEvent); return valueChanged ? filteredNodes : value; }, @@ -648,6 +646,28 @@ export default { isNodeLeaf(node) { return node.leaf === false ? false : !(node.children && node.children.length); }, + createLazyLoadEvent(event) { + let filterMatchModes; + if (this.hasFilters) { + filterMatchModes = {}; + this.columns.forEach(col => { + if (col.field) { + filterMatchModes[col.field] = col.filterMatchMode; + } + }); + } + + return { + originalEvent: event, + first: this.d_first, + rows: this.d_rows, + sortField: this.d_sortField, + sortOrder: this.d_sortOrder, + multiSortMeta: this.d_multiSortMeta, + filters: this.filters, + filterMatchModes: filterMatchModes + }; + }, onColumnResizeStart(event) { let containerLeft = DomHandler.getOffset(this.$el).left; this.resizeColumnElement = event.target.parentElement; diff --git a/src/views/treetable/TreeTableDoc.vue b/src/views/treetable/TreeTableDoc.vue index 9265a5476..cbfc0462a 100644 --- a/src/views/treetable/TreeTableDoc.vue +++ b/src/views/treetable/TreeTableDoc.vue @@ -1440,26 +1440,45 @@ export default { page - event.page: New page number
+ event.originalEvent: Browser event
+ event.page: New page number
+ event.pageCount: Total page count
event.first: Index of first record
event.rows: Number of rows to display in new page
- event.pageCount: Total number of pages + event.sortField: Field to sort against
+ event.sortOrder: Sort order as integer
+ event.multiSortMeta: MultiSort metadata
+ event.filters: Collection of active filters
+ event.filterMatchModes: Match modes per field - Callback to invoke on pagination. + Callback to invoke on pagination. Sort and Filter information is also available for lazy loading implementation. sort - event.originalEvent: Browser event.
- event.sortField: Field to sort against.
- event.sortOrder: Sort order as integer.
- event.multiSortMeta: MultiSort metadata. - Callback to invoke on sort. + event.originalEvent: Browser event
+ event.first: Index of first record
+ event.rows: Number of rows to display in new page
+ event.sortField: Field to sort against
+ event.sortOrder: Sort order as integer
+ event.multiSortMeta: MultiSort metadata
+ event.filters: Collection of active filters
+ event.filterMatchModes: Match modes per field + + Callback to invoke on sort. Page and Filter information is also available for lazy loading implementation. filter - event.filters: Collection of active filters.
- event.filteredValue: Filtered collection. - Callback to invoke on filtering. + event.originalEvent: Browser event
+ event.first: Index of first record
+ event.rows: Number of rows to display in new page
+ event.sortField: Field to sort against
+ event.sortOrder: Sort order as integer
+ event.multiSortMeta: MultiSort metadata
+ event.filters: Collection of active filters
+ event.filteredValue: Filtered collection
+ event.filterMatchModes: Match modes per field + + Event to emit after filtering, not triggered in lazy mode. node-select