Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to insert custom sorting function #559

Closed
bst27 opened this issue Feb 15, 2016 · 2 comments
Closed

Allow to insert custom sorting function #559

bst27 opened this issue Feb 15, 2016 · 2 comments

Comments

@bst27
Copy link

bst27 commented Feb 15, 2016

According to the API documentation a sortChildren function exists which can be called to sort children based on a custom sorting function.
I would like to suggest to allow replacing the existing sorting function instead of calling the sortChildren function on demand. With the existing approach the API user has to know when to call sortChildren to preserve correct node order. With the possibility to insert a permanent sorting functionality like suggested above the API user is able to achieve a custom sorting without having to care for internal implementation details (knowing when to call sortChildren again).

@mar10
Copy link
Owner

mar10 commented Sep 3, 2016

This could be based on a concept of modification events (see also #419 )
For this special purpose however a childrenModified event would suffice, and we even only would have to listen for adding nodes, since deletions would not affect sort order.

@mar10
Copy link
Owner

mar10 commented Sep 3, 2016

Since sorting may be based not only on the title, but also on custom data properties, I think offering a new modify event is a more flexible and general approach. This would allow a simple pattern like

modify: function(event, data) {
    if( data.operation === "add" ) {
        data.node.sortChildren(...);
    }
}

So closing this in favor of #419

@mar10 mar10 closed this as completed Sep 3, 2016
mar10 added a commit that referenced this issue Sep 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants