amsik / liquor-tree

Tree component based on Vue.js
MIT License
398 stars 94 forks source link

Feature request for setting default sort function as property of Component options #215

Open hjelperne opened 4 years ago

hjelperne commented 4 years ago

Hi,

I have searched existing liqour-tree issues and fount the previous reply you had regarding liqour-tree sorting: https://github.com/amsik/liquor-tree/issues/92

By using the mentioned example (https://jsfiddle.net/amsik/02zhLpkw/) I have managed to achieve my desired result - which is insensitive sorting in Norwegian.

I added the following code onTreeMounted:

const norwegianLocale = 'nb-NO' function sort(node0, node1) { return node0.text.toLowerCase().localeCompare(node1.text.toLowerCase(), norwegianLocale) } this.$refs.tree.sortTree(sort)

My question is if it is possible to add "sort" prop to Component options - so one can simply pass a desired function as a prop - to set the default sorting as desired - sort of cleaner approach in my opininon

By the way - thanks for making this excellent project available - the best tree component I have come across for Vue!

Best regards H