Comments (4)
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.
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.
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.
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)
- ColumnSets with CompoundColumns and ColumnResizer does not always resize correctly.
- horizontal scrolling alignment issue dgrid
- horizontal HOT 1
- rowindex HOT 1
- Is this project still maintained? HOT 2
- DGrid 'select all' checkbox is not working as expected HOT 2
- OnDemandList does not refresh on store.setData HOT 2
- build issues with dojo 1.16 HOT 7
- Editor focusout handler is stopped when a row is removed
- CheckBox Editor does not work as expected in Safari HOT 3
- Removed row handing in Editor onblur HOT 2
- Editor: browser blur with active Select leads to bugged editor
- Update Intern from 3 to 4
- (ColumnSet +) CompoundColumns_findSortArrowParent(field) fails to find parent out of the 1st column set
- Website still points to v1.2.1
- Dgrid selector inconsistently working in touch screen devices like ipad dgrid/v1.1.0 HOT 10
- dgrid version 1.3.3 is breaking formatter function in dgrid HOT 2
- How to set dgrid editor checkbox readonly conditionally ?
- dgrid does not throw error on scroll (http-status-code) HOT 2
- dgrid.cell().element is undefined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dgrid.