• Post Reply Bookmark Topic Watch Topic
  • New Topic

Drag and Drop data from one TableView to another  RSS feed

Vasilis Souvatzis
Ranch Hand
Posts: 94
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry for this noob question but my head is spinning from reading all sorts of code and book samples, I still don't know how to do this.

I've made an FXML app and put TableViews, the source (MainDB) and the targets (table1, 2, 3). The MainDB loads stuff from a database. I want to Drag'N'Drop rows of data from the MainDB to table1.

What my simple mind thinks I should do in the Controller class is this: a) on MainDB when OnDragDetected, store the row in a temp var

b) on target when OnDragDropped, add temp in a ObservableList which in turn is added to the target.

The code i have in my Controller is this:

These tableviews reside in a SplitPane, one tableview on the right (mainDB) and the other on the left. Maybe the drag event doesn't "see" the tableview on the left? The sample code on JavaFX docs are clear, I understand it. What confuses me (probably), is that I'm attempting a two-step operation here where on the samples they use multi-step operations.

The copyFromSource event fires when I try to drag, not the addToTarget though...

I've managed to find a workaround to this, by using a click event to select a row from the mainDB and double click on target to set the data. It's not ideal though, I was planning on using the double click event on another operation...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!