Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dragging data from a TreeGrid to PortalLayout drags the entire TreeGrid object instead.

    The test case is based on this example: https://smartclient.com/smartclient/...ntentsDragging
    Reproducible with the latest live version and 13.0 Pro in Chrome and FF.

    In this example, when the records are being dragged from a ListGrid, everything works. Records are getting accepted as portlets within the PortalLayout.
    However, the same operation doesn't work when using the TreeGrid instead of the ListGrid. In case of the TreeGrid, the actual TreeGrid object ends up being included as a portlet, not the record being dragged from it.

    The code below is basically a combination of https://smartclient.com/smartclient/...ntentsDragging and https://smartclient.com/smartclient/...=treesDragTree examples.

    Select the "Blue Cube" in the TreeGrid and drag it into any PortalLayout column.

    Code:
    isc.defineClass("PartsListGrid","ListGrid").addProperties({
        cellHeight: 24,
        imageSize: 16,
        showEdges: true,
        border: "0px",
        bodyStyleName: "normal",
        alternateRecordStyles: true,
        showHeader: false,
        leaveScrollbarGap: false,
        defaultFields: [
            {name: "partSrc", type: "image", width: 24, imageURLPrefix: "pieces/16/"},
            {name: "partName"},
            {name: "partNum", width: 20}
        ],
        trackerImage: {src:"pieces/24/cubes_all.png", width: 24, height: 24}
    })
    
    isc.PartsListGrid.create({
        ID: "myList",
        data: exampleData,
        canDragRecordsOut: true,
        canReorderRecords: true,
        dragDataAction: "copy"
    }),
    
    isc.PortalLayout.create({
        ID: "portalLayout",
    
        getDropPortlet : function (dragTarget, colNum, rowNum, rowOffset) {
            // You can use getDropPortlet to customize what happens when a component is dropped
            if (dragTarget.isA("PartsListGrid")) {
                return isc.Portlet.create({
                    title: "Dragged Records",
                    items: [
                        isc.PartsListGrid.create({
                            data: dragTarget.getDragData()
                        })
                    ]
                });
            } else {
                // By default, the whole component is wrapped in a Portlet
                return this.Super("getDropPortlet", arguments);
            }
        }
    });
    
    isc.defineClass("DragPiece", "Img").addProperties({
        width: 48,
        height: 48,
        padding: 12,
        layoutAlign: "center",
        canDragReposition: true,
        canDrop: true,
        dragAppearance: "target",
        appImgDir: "pieces/48/"
    })
    
    isc.VStack.create({
        ID: "myImages",
        membersMargin: 10,
        layoutMargin: 10,
        showEdges: true,
        members: [
            isc.DragPiece.create({src:"pawn_blue.png"}),
            isc.DragPiece.create({src:"pawn_green.png"}),
            isc.DragPiece.create({src:"pawn_yellow.png"})
        ]
    })
    
    isc.HLayout.create({
        width: "100%",
        height: "100%",
        membersMargin: 20,
        members: [
            portalLayout,
            isc.VLayout.create({
                width: 200,
                membersMargin: 10,
                members: [
                    myList,
                    myImages
                ]
            })
        ]
    });
    
    
    //TREE
    isc.Tree.create({ID:"partsTree1", root:{children:[
        {name:"Bin 1", children:[
            {name:"Blue Cube", icon:"cube_blue.png"},
            {name:"Yellow Cube", icon:"cube_yellow.png"},
            {name:"Green Cube", icon:"cube_green.png"}
        ]},
        {name:"Bin 2", children:[
            {name:"Blue Piece", icon:"pawn_blue.png"},
            {name:"Yellow Piece", icon:"pawn_yellow.png"},
            {name:"Green Piece", icon:"pawn_green.png"}
        ]}
    ]}})
    
    partsTree1.openAll();
    
    isc.defineClass("PartsTreeGrid","TreeGrid").addProperties({
        width:200, height:200,
        showEdges:true, border:"0px", bodyStyleName:"normal",
        alternateRecordStyles:true, showHeader:false, leaveScrollbarGap:false,
        emptyMessage:"Drag & drop parts here",
        manyItemsImage:"cubes_all.png",
        appImgDir:"pieces/16/"
    })
    
    isc.HStack.create({membersMargin:10, height:160, members:[
        isc.PartsTreeGrid.create({
            ID:"myTree1",
            data: partsTree1,
            canReorderRecords: true,
            canAcceptDroppedRecords: true,
            canDragRecordsOut: true,
            dragDataAction: "move"
        })
    ]})

    The same behavior is reproducible with ListGrids that contain grouped data. So the grid from this example will get dragged to the portal layout as well: https://smartclient.com/smartclient/...=multiGrouping

    Thank you.
    Last edited by genev; 5 Jan 2024, 16:54.

    #2
    Your check in your override of getDropPortlet() only looks for a PartsListGrid, but your TreeGrid subclass is a PartsTreeGrid, which is not a subclass of PartsListGrid.

    Your claim about a similar problem with grouped ListGrids is probably the same problem, if you just tried to include your getDropPortlet() override as-is into that sample.

    Comment

    Working...
    X