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

add custom node filter to generateFormElements #595

Closed
allenfantasy opened this issue May 3, 2016 · 3 comments
Closed

add custom node filter to generateFormElements #595

allenfantasy opened this issue May 3, 2016 · 3 comments

Comments

@allenfantasy
Copy link

allenfantasy commented May 3, 2016

First thanks for this brilliant library 👍

Here I use the generateFormElements method to create form elements before submitting the selected nodes. However I found that I don't need to submit unselectable nodes since they are locked and user shouldn't update them.

Also I found the generateFormElements have used getSelectedNodes where it picks up only selected nodes - but I would like to picked up partsel nodes as well and exclude all unselectable nodes.

Sure I could hack the original source code the achieve this but I think it's better to raise the issue here to hear your advice first :)

So here it goes:

Expected behavior

Enable user customize the returned nodes in generateFormElements. IMHO it could be achieved by either way:

  • Providing a configurable option in FancytreeOptions
  • Providing a configurable option when calling the generateFormElements method.

Environment

  • Browser type and version: Chrome 50.0.2661.86 (64-bit)
  • jQuery and jQuery UI versions: 1.12.3 / 1.11.4
  • Fancytree version: 2.17.1
  • enabled/affected extensions: table, dnd enabled
@mar10
Copy link
Owner

mar10 commented May 3, 2016

generateFormElements() already has an optsargument. We could add an additional option (e.g. otps.filter) that accepts a callback function.

If specified, tree.generateFormElements() would use visit()instead of getSelectedNodes(), call filter(node), and serializes all nodes that we return true for?

@allenfantasy
Copy link
Author

Thank you for your reply :)

Yes - I think the addition option could be opts.filter and if opts.filter is defined we use visit() to call filter(node) to return wanted nodes.

@mar10
Copy link
Owner

mar10 commented Aug 12, 2016

(see also #310)

@mar10 mar10 closed this as completed in 35242f2 Nov 6, 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