Skip to content

Commit ea92ae7

Browse files
committed
feat: CDataTable - add filtered-items-change event
1 parent e3fcf96 commit ea92ae7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/components/table/CDataTable.vue

+14-4
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,7 @@ export default {
297297
}
298298
},
299299
items (val, oldVal) {
300-
if (
301-
val && oldVal && val.length === oldVal.length &&
302-
JSON.stringify(val) === JSON.stringify(oldVal)
303-
) {
300+
if (val && oldVal && this.objectsAreIdentical(val, oldVal)) {
304301
return
305302
}
306303
this.passedItems = val || []
@@ -310,6 +307,15 @@ export default {
310307
handler (val) {
311308
this.$emit('pages-change', val)
312309
}
310+
},
311+
sortedItems: {
312+
immediate: true,
313+
handler (val, oldVal) {
314+
if (val && oldVal && this.objectsAreIdentical(val, oldVal)) {
315+
return
316+
}
317+
this.$emit('filtered-items-change', val)
318+
}
313319
}
314320
},
315321
computed: {
@@ -517,6 +523,10 @@ export default {
517523
paginationChange (e) {
518524
this.$emit('pagination-change', Number(e.target.value))
519525
this.perPageItems = Number(e.target.value)
526+
},
527+
objectsAreIdentical (obj1, obj2) {
528+
return obj1.length === obj2.length &&
529+
JSON.stringify(obj1) === JSON.stringify(obj2)
520530
}
521531
}
522532
}

0 commit comments

Comments
 (0)