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

Update Single Node #1763

Closed
EnergyTeam opened this issue May 17, 2017 · 3 comments
Closed

Update Single Node #1763

EnergyTeam opened this issue May 17, 2017 · 3 comments

Comments

@EnergyTeam
Copy link

I have this problem, I find a folder with children, I would like to have the ability to update some attributes of the folder without deleting all the children and without having to re-insert all the tree dates, I would like a function that could be "Update_node" to update from an existing element only that node without losing the children, is it possible?

I tried to use create_node but obviously deleted all children..

Can you help me?

Thanks

@vakata
Copy link
Owner

vakata commented May 18, 2017

I guess you do not need to change the "standard" properties, which you can do with: set_id, rename_node, set_icon, etc.

If you need additional changes - you can change the node object directly:

var node = $('#tree-container-id-here').jstree(true).get_node('node-id-here');
node.a_attr.href = 'https://www.jstree.com';
node.data.some_property = 'some_value';

You may have to redraw the parent if the node is already rendered and you are changing some properties that affect the rendering (or if that is too expensive for you - you can change the DOM attributes manually as you change them in the object).

If this does not answer your question let me know and I will reopen.

@rpcabrera
Copy link

Hi, vakata!, as EnergyTeam asked, is there any way to reload the json data from a single node? This is my case: I have a product's categories tree with a subcategories hierarchy. Then added a context-menu with an "Edit" action, which renders a modal with category (node) information. The update only affects the selected node (properties), not its inside structure. Finally, I want to refresh only the node by ajax. I tried with refresh_node and load_node methods, but they only reload the node children, not self data. As you answered, I can mannually set node properties, but in my case I have 16 properties in node. Any suggestion?

@vakata
Copy link
Owner

vakata commented Nov 21, 2019

There is nothing built-in, but whether it is 1 or a 100 properties - the method above will work. You can go over all the properties the server returns (in your custom code), and apply those to the node, you do not have to hard-code all 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants