Code Monkey home page Code Monkey logo

Comments (5)

stefanloerwald avatar stefanloerwald commented on July 17, 2024

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.

antwjadam avatar antwjadam commented on July 17, 2024

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.

stefanloerwald avatar stefanloerwald commented on July 17, 2024

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.

antwjadam avatar antwjadam commented on July 17, 2024

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.

stefanloerwald avatar stefanloerwald commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.