What version are you using?
2.15.0
What browser?
Chrome 69.0.3497.100, Safari 12.0
Sort changes when clicking on column headers
Sort does not change
https://jsfiddle.net/gira82/cq4etkp6/1/
Basically I need to have an array of ids related to selected rows.
So I have a selectionChanged method that reduce the rows selected to an array of ids.
In the fiddle I attached there are three things that make the sort working:
I think there is something not working properly in the sorting code.
Thank you
you need to take care of the 0 length case when sort is changed:
This will make your jsfiddle work.
selectionChanged(params) {
/* console.log(params) */;
if (!params.selectedRows.length) {
this.selectedIds = [];
return;
}
const selectedIds = params.selectedRows.reduce((acc, row) => {
acc.push(row.id)
return acc
}, [])
console.log(selectedIds);
this.selectedIds = selectedIds
}
closing.
Sorry, but the .reduce correctly returns an empty array when params.selectedRows is empty.
In my humble opinion, the point is not this, and the sort is still not working in the updated fiddle: https://jsfiddle.net/gira82/cq4etkp6/18/
I carefully debug the problem before I opened the issue, and I cannot see any problem in this simple code.
It's curious that removing initialSortBy all starts to work.
I can make more tests if needed.
apologies for the initial haste, I'll re-open this. However if i comment out this.selectedIds assignment... everything seems to be working fine. I'll debug it more.
looks like if I don't print out {{ selectedIds }} , everything is working as well. strange.
Yes, as I wrote at the beginning, three things will make the script work:
1 and 2 sound inexplicable to me (after about 2 years of Vue developing)
If you look at console, it seems that the method is triggered three times every time you change sorting.
Hope this will help.
so just published 2.15.2 and seems to have passed all my tests... I'm going to keep this open for a bit so we can test with your jsfiddle
ok tested with your fiddle... seems to be working well now. Thanks for reporting this!
Thank you to you for so fast fix! 馃憤