Login Register

How to drag and drop a row from Grid

Hi,

We are having problems in dragging and dropping a row from the Grid (dojox.grid) to a shopping cart container. Usually the drag and drop works and drag's a source DIV to a target DIV and they have specific class names. But we are unable to do the same with the Grid.

Has anyone tried to do this?

Any ideas would greatly help.

An open ticket for Dojo Grid needing DND event

Hello,

My colleague just found an open ticket which may be the answer. It
seems that Dojox.grid does not have an event defined for the Drag
event.

http://trac.dojotoolkit.org/ticket/4984

And that must be the reason why Plants by WebSphere is not using the Dojo's Grid component.

Now this ticket was open a month ago. Is there any way to track the
progress of this ticket and see if there is any interim solution?

Thanks so much,

Best Regards,
Maan Mehta

an idea or a hack to get ths working?

Is it possible to wrap each row (dojox.grid) with either a table with one row (tr) and then a single column (td). And then following the Plants by WebSphere example, we know that the TD element can listen for the DND events and anything inside that TD can be dragged and dropped to the Target. So, if the Grid's row is inside our TD element, it may just work. We will try and get back. If this works, it will be an easy workaround until they officially add the DND event to Grid's row and cells.

Thanks so much,

Best Regards,
Maan Mehta

Did you ever try this? I'd

Did you ever try this? I'd like to figure out a clean way just to get a mouseup mousedown events to a cell so that I can roll my own drag & drop in the mean time. Any ideas on how to do this? Seems like it should be simple -- I've tried a few things and nothing seems to work.

temporary hack 'till grid has drag / drop

Ok -- just in case this helps anyone else; what I did was to first direct the needed events up to where I could make use of them. (this is just a hack -- there's gotta be a better way to do this)

dojo.declare('dojox.DLGrid', dojox.Grid, {

	postCreate: function(){
	   this.inherited(arguments);
	   this.funnelDDEvents();
	},
	
	funnelDDEvents : function() {
       dojox.grid.funnelEvents(this.views.views[1].contentNode, this.views.views[1], "doContentEvent", [ 'mousemove', 'mousedown', 'mouseup' ]);	   
        // I think this.views.views[0] is the grid gutter
	},

    setStructure : function(args) {
        this.inherited(arguments);
        this.funnelDDEvents();
    },

	domousedown: function(e) {
	   console.debug('DLGRID: mousedown');
           // record mousedown here
	},

        domousemove: function(e) {
	   console.debug('DLGRID: mousemove');
           // at this point e is decorated and contains info about the cell 
           // if mouse down recorded, and the cell is dragable, etc, then you can 
                ddm = dojo.dnd.manager();
                ...
                ddm.startDrag(.....);
                // I actually made the grid the source & target by adding the need functions

                // if draggging then use e.cell to look at the cell and determine canEdit and then 

                ddm.canDrop(canEdit);

	},
	domouseup: function(e) {
	   console.debug('DLGRID: mouseup');
           // if dragging then use e.cell to look at the drop target and then 
           ddm = dojo.dnd.manager();
           ddm.stopDrag();

	},

This was a hack, but should help a lot if you *really* need a simple grid d&d like I did. (we're trying to arrange an orchestra where each grid cell is actually a modified FilteringSelect which can do a name lookup).

Also, it would be nice if dojo.dnd.Manager could operate with a null source and target so as to lend itself to doing something manually like this. This class *is* quite useful with the source & targets not set for moving the avatar, but causes erros if the source & target == null. Not sure if this justifies filing a bug ....?

Hi dlewicki, Can you please

Hi dlewicki,

Can you please post the full code.
I am a beginner to Dojo & finding it difficult to understand the code you pasted.
Thanks in Advance.

Regards

full source for example

dlewicki, do you think you could post a full working example? i'm having a hard time understanding exactly how to reproduce your workaround without the other changes to make the grid a source/target.

can't figure this out!

i second marktrumbo's request. i've been trying to get drag and drop of grid rows to work as well, but can't even with the example above. if someone could post more complete source code that'd be great!

Any updates?

Has anyone found a solution to this problem? I need D&D support in the DataGrid for a project and will get it one way or anything :/. Is anyone actively working on developing d&d support, or is this just going to be another vapor feature :/.

aim: john2496