Comments (5)
Hi @antwjadam,
Defining additional parameters (including event handlers) to nodes is generally not supported. You can get updates to the node positions by binding to their coordinates. That way, the property you're binding to is always kept up-to-date.
BR
Stefan
from blazor.diagrams.
Yup, I have the binding to the co-ordinates, so that when retrieving my node list from the db, the diagram draws correctly. What I need though is to catch the event that the node on the diagram is dragged to a new position, The diagram rendered is showing the node in the new position fine, the x,y bindings give the new co-ordinates fine. But I need to trigger an update to the database to update the co-ordinates on the database record for that node.... something like in pseudo code
... node has moved event is triggered (this is the thing I cant work out - how to detect the change)
... get the new x,y from the bound values
... using the node id, find the node record on the database for that id (I can do this bit)
... update the x,y on the database to the new values (this is easy)
I did notice the selection change event triggers when clicking on the node to start dragging it, and fires again when releasing the node in its new position, so I though I could maybe using the reference to the diagram, step through all the nodes looking for x,y updates needed to be done on the db.
from blazor.diagrams.
I see. While you can technically just modify the bind to perform more operations on ValueChanged, I would advise against that, because it would fire for every tiny little change, even during the move. I'm working on a larger code refactoring of mouse interaction at the moment, so I'll have a look into adding such an event while I'm at it.
from blazor.diagrams.
Thanks!
At the moment, I am going to try this in my selection change event (its a bit sledge hammer to crack a nut but will get me what I need for now)
// all nodes deselected so check for x,y change
foreach (var nodeRendered in diagramNodes)
{
var nodeDatabase = nodesService.GetNodeById(nodeRendered.Id);
if (nodeRendered.X == nodeDatabase.X && nodeRendered.Y == nodeDatabase.Y) continue;
nodesService.UpdateNodeXY(nodeRendered.Id, nodeRendered.X, nodeRendered.Y)
}
from blazor.diagrams.
This is now part of v3.12.0: You get a OnModified
event callback on the Nodes
. Please let me know in case it doesn't work for you.
from blazor.diagrams.
Related Issues (20)
- Creating custom link HOT 6
- Diagram Does Not Display HOT 3
- Property Hidden HOT 2
- Questions HOT 2
- Disabling Custom Links HOT 3
- NodeLibrary with Code generated Nodes HOT 7
- additional arrow styles? HOT 2
- Is it possible to disable the function that lets you click on an object and link it to another? HOT 5
- Diagram LinkModified LinkBase param doesnt provide correct positions on source and node HOT 5
- Is there a way to make lines not lap over nodes during auto layout HOT 2
- Auto Layout after render HOT 1
- Panning on mobile HOT 2
- Allow custom middle point and link direction of AngleLink component HOT 6
- Callback after graph is rendered? HOT 8
- Adding container element/nesting of nodes HOT 1
- AutoLayout HOT 6
- Auto-Center after ZoomToFit HOT 7
- Improve documentation about how to change size of nodes.
- Add the ability to prevent remove node or link
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazor.diagrams.