B4J Question TreeTableView drag & drop

RJL

Member
Sorry if this is dumb question. How do I update a cell on a TreeTableView? I'm using jDragAndDrop which is working fine but don't know how to actually update a TreeTableView cell. Here is what I have but this produces an error

Dim source_ob As Object
Dim dest_ob As Object
Dim tti As TreeTableItem
Dim col As Int = 3
Log("DragDropped : DataId " & e.GetDataIds(0) & " is to be dropped")
source_ob = e.GetDataObjectForId("DTSource")
dest_ob = e.GetGestureTarget
tti = dest_ob
tti.SetValue(col, source_ob ) 'produces following error

java.lang.ClassCastException: javafx.scene.control.TreeTableView cannot be cast to javafx.scene.control.TreeItem
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Please use [CODE]code here...[/CODE] tags when posting code.

codetag001.png

codetag002.png

codetag003.png
 
Upvote 0

RJL

Member
Sorry...

B4X:
Sub DestView_DragDropped(e As DragEvent)
    If e.GetDataIds(0) = "DTSource" Then ' it's from this program
        Dim source_ob As Object
        Dim dest_ob As Object
        Dim tti As TreeTableItem
        Dim col As Int = 3
        Log("DragDropped : DataId " & e.GetDataIds(0) & " is to be dropped")
        source_ob = e.GetDataObjectForId("DTSource")
        dest_ob = e.GetGestureTarget

        tti = dest_ob
        'tti.SetValue(col, source_ob )
        
        e.SetDropCompleted(True)
        Return
    End If
    
End Sub

On "ttl.SetValue" I'm getting: java.lang.ClassCastException: javafx.scene.control.TreeTableView cannot be cast to javafx.scene.control.TreeItem
 
Upvote 0

RJL

Member
Thank you for the reply. I guess my question is, how do I update a specific row and column of the TreeTableView? I'm not having any success with the "SetValue" method. I'm new to this and if there is some documentation on this it would be helpful. I wasn't able to find much.

I think I might be lacking some fundamental understanding.
 
Last edited:
Upvote 0

RJL

Member
Thank you very much for the links. Unfortunately, the SelectedItem event isn't triggered during drag/drop. I am dragging from a TableView to a TreeTableView. I can see and use the drag item easily, however, the drop object is a TreeTableView. I don't know how to 1) get to the dropped TreeTableItem and 2) update the value of the TreeTableItem.
 
Last edited:
Upvote 0

RJL

Member
Let me try this again. I have set up drag/drop as follows:


B4X:
Sub Process_Globals
Private DragDrop As DragAndDrop
Private SourceFields As TableView
Private DestView As TreeTableView
Private DestItem As TreeTableItem
End Sub

Sub AppStart (Form1 As Form, Args() As String)
      DragDrop.MakeDragSource(SourceFields, "SourceFields")
    DragDrop.MakeDragTarget(DestView, "DestView")
...
End Sub

In the DestView_DragDropped(e As DragEvent) I can see the target using debug in e.target.treeTableRow.value.item.value but I don't know how to access/update the cell.
 
Upvote 0

RJL

Member
Here is the project. I have included a screenshot
of how it looks when connected to my SQL database.
 

Attachments

  • MyProject.zip
    19.3 KB · Views: 346
Upvote 0
Top