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
Give node id as per your choice #126
Comments
Hello @ishpreetkaurwebner The node id cannot be passed. It is self-assigned. Only on import can you pass the id of the node. Maybe you could change it with the "nodeCreated" event but it is not recommended. Why do you need to know the id? Jero |
The key question is why you want to set IDs. If your application need that node id be unique and never the same on different flows, you may set:
After that, all the IDs generated will be UUIDs instead of autoincrement integers, unique for any node created. However, if you copy one flow from other, it is your duty to re-asign all the IDs to got clear new instance. |
Is there anything like data-attr we can assign to node like we pass name and class to addNode()? I want to pass extra information, custom id we can't provide work according to you, so can we use our custom information on data-attr or any other suggestion you have? |
You could create a custom html with a unique id for each node. Or take the id assigned to it with the "nodeCreated" event. Or create a hidden input with df- * variables and assign the variable to creation. |
Or just add a property to a node and the property will survive export-import. |
Ok, thanks a lot, I will try |
I have a use case for this. Im using Drawflow to render and edit some graph which is already saved in a database. Every node is a db row with self generated ids (primary keys), completely incompatible with the ids generated by drawflow... A workaround would be to first create a new db row with a post, then import the data all over again, but that doesn't sound very smart (: |
Hello @rsvidevince Override the function uuid to get last insertdID in your db. |
Hmm, that sounds smarter! Can you give me a hint on how/where to do this ? |
Use: editor.useuuid = true;
editor.getUuid = function() {
/*
Your code for las insert db
*/
return your_last_inset_db;
} |
Thanks for your help @jerosoler ! |
Mmmmmm editor.getUuid = async function() {
/*
Your code for las insert db
*/
return your_last_inset_db;
} ¿? |
I tried :T
Prints in the console like this:
Similarly:
prints:
|
Separe functions in two functions. |
I tried that way too, unfortunately :T
Prints:
I've changed my logic a little, and made it! I'm running editor.addNode() only after the post, than I can return the new id synchronously with getUuid(). |
I need to get the html elements of a particular node to update the values of that node and that node is separate component... |
In editor.addNode() function, we can pass name, input, output, position x, position y, class, and html. How we can pass node id and give node id according to our choice?
The text was updated successfully, but these errors were encountered: