Skip to content

Selecting nodes programmatically #873

Answered by bcakmakoglu
SciManJD asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry, I sent this message while outside so wasn't able to write a lot more than this 😄
There's a couple ways to select nodes programmatically but the easiest way is, as I mentioned, to just set node.selected to true

For example:

const { findNode } = useVueFlow()

const node = findNode(someId)

if (node) {
	node.selected = true
}

And that's it, your node is now marked as selected :)

Alternatively there's the option to use the addSelectedNodes action.

const { addSelectedNodes } = useVueFlow()

addSelectedNodes(someNodesArray)

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@bcakmakoglu
Comment options

Answer selected by bcakmakoglu
@SciManJD
Comment options

@bcakmakoglu
Comment options

@SciManJD
Comment options

@bcakmakoglu
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants