Giter Club home page Giter Club logo

Comments (4)

zernyu avatar zernyu commented on June 17, 2024

I was able to patch this by adding this to extensions/DnD.js:
In postMixInProperties, in the this.dndTargetConfig object, I added:

/**
 * Overriding function in Container.js to handle detecting Tree child nodes for DND
 */
_getChildByEvent: function(event) {
    var node = event.target;
    if (node) {
        for (var parent = node.parentNode; parent; node = parent, parent = node.parentNode) {
            // Check if the node is a dnd item and also a valid dgrid row (uppermost node under a containing div)
            if ((parent == this.parent || dojo.hasClass(parent, 'dgrid-tree-container'))
              && dojo.hasClass(node, 'dojoDndItem')) {
                return node;
            }
        }
    }
    return null;
}

This is copied from line 344 of dojo/dnd/Container.js to override the function that checks to see which node your mouse is over. Hoping the dgrid guys come up with a more elegant solution!

from dgrid.

 avatar commented on June 17, 2024

FYI, Kris logged a bug with Dojo about this inherent limitation in dojo/dnd, and it seems there's a bit of interest in supporting this in general, with a patch currently in the works. http://bugs.dojotoolkit.org/ticket/14901

from dgrid.

billdwhite avatar billdwhite commented on June 17, 2024

This is still broken and also, even with the fix suggested by swiftdemise, only CTRL selections work. Shift selections only grab the first and last items in the selected range for dragging.

Here is a code sample that demonstrates the problem:


        require(["dojo/_base/declare", "dojo/ready", "dojo/dom", "dojo/on", "dojo/_base/window", "dojo/_base/Deferred","dgrid/OnDemandGrid","dgrid/tree", "dgrid/Selection", "dgrid/Keyboard",  "dgrid/extensions/DnD", "dojo/store/Memory", "dojo/store/Observable", "dojo/store/util/QueryResults", "dojo/dnd/Source"],
                function(declare, ready, dojoDom, on, win, Deferred, OnDemandGrid, tree, Selection, Keyboard, DnD, Memory, Observable, QueryResults, DnDSource) {
                    ready(function() {

```
                    var testCountryStore = Observable(new Memory({
                        data: [
                            { id: 'US', name:'USA', type:'country', parent: 'NA' },
                            { id: 'New York', name:'New York', type:'city', parent: 'US' },
                            { id: 'Chicago', name:'Chicago', type:'city', parent: 'US' },
                            { id: 'Dallas', name:'Dallas', type:'city', parent: 'US' },
                            { id: 'Los Angeles', name:'Los Angeles', type:'city', parent: 'US' },
                            { id: 'Denver', name:'Denver', type:'city', parent: 'US' },
                            { id: 'Miami', name:'Miami', type:'city', parent: 'US' },
                            { id: 'Boston', name:'Boston', type:'city', parent: 'US' }
                        ],
                        getChildren: function(parent, options){
                            return this.query({parent: parent.id}, options);
                        },
                        mayHaveChildren: function(parent){
                            return parent.type != "city";
                        },
                        query: function(query, options){
                            var def = new Deferred();
                            var immediateResults = this.queryEngine(query, options)(this.data);
                            setTimeout(function(){
                                def.resolve(immediateResults);
                            }, 200);
                            var results = QueryResults(def.promise);
                            return results;
                        }
                    }));

                    var DnDGrid = declare([OnDemandGrid, Selection, DnD, Keyboard]);

                    var grid1 = new DnDGrid({
                        store: testCountryStore,
                        columns: [
                            {label: "Name", field:"name", sortable: false},
                            {label:"Type", field:"type", sortable: false},
                            {label:"Population", field:"population"},
                            {label:"Timezone", field:"timezone"}
                        ]
                    }, "grid1");
                    var grid2 = new DnDGrid({
                        store: testCountryStore,
                        query: {type: "country"},
                        columns: [
                            tree({label: "Name", field:"name", sortable: false}),
                            {label:"Type", field:"type", sortable: false},
                            {label:"Population", field:"population"},
                            {label:"Timezone", field:"timezone"}
                        ]
                    }, "grid2");

                    var anotherTargetDiv = dojo.byId("another-target");
                    var target = new DnDSource(anotherTargetDiv, {accept:["dgrid-row"], isSource:false});
                });
            }
    );
```

from dgrid.

 avatar commented on June 17, 2024

Firstly, RE the original topic, dragging of tree children should work now with Dojo 1.8 which added support for an allowNested property on DnD sources (as per the aforementioned dojo ticket). I've added a test page at test/extensions/DnD_tree.html to demonstrate this briefly.

Secondly, RE selection, there were some commits a few weeks ago that should resolve some issues regarding synchronizing selection between dojo/dnd and dgrid, so give that another try.

I'm closing this out now, but if you do see issues feel free to open new ones. Thanks!

from dgrid.

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.