igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

Drag and Drop the selected row in igx-grid

Open pnishimura opened this issue 7 years ago • 10 comments

Is your feature request related to a problem? Please describe.

Want to drag the selected row (not the selected cell) in igx-grid and drop it on other grids, lists or some other area. I know this can achieve by cell, but want to achieve by row. This means that I want to copy the whole cell data in a row to another area.

Note that I do not need to drag and drop multiple rows simultaneously.

Describe the solution you'd like

  • Change the interface to set the custom function to igxDrag's property in order to set the ghost.
  • The parameters of the custom function to set the ghost should be the dragging source node and the return value should be the ghost node.
  • When create the ghost, if set the custom function, it will be called. if set nothing, the default setting will be used.

The proposal code change is just like below.

https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/dragdrop/dragdrop.directive.ts#L582 At the line #582

Current this._dragGhost = node ? node.cloneNode(true) : this.element.nativeElement.cloneNode(true);

Proposal code change this._dragGhost = this.XXXXX ? this.XXXXX(node) : node ? node.cloneNode(true) : this.element.nativeElement.cloneNode(true); Note that XXXXX is the custom function name to be able to set the ghost.

Describe alternatives you've considered

The proposal code change might be just a temporary measure, If you guys have alternative ideas and code changes, it would also be great. e.g.) Add a new event igx-grid to capture the row which can be drag-gable.

Additional context

pnishimura avatar Feb 23 '19 01:02 pnishimura

@pnishimura For dragging and dropping rows we can have the following alternatives:

  1. Expose a drag+drop UI, in the form of an icon that apprears in front of the row, like the row selection checkbox, which upon drag will trigger an event, which the dev can consume, and upon drop would trigger another event that the dev can consume.

The default behavior would be that if none of the events are handled, then the dragged and dropped row ghost would always revert back to the position of the row. If handled, then the behavior would be defined by the dev.

The dragging would be performed on one row at a time, and would not be related to row selection. It would also be toggleable, and by default would not be turned on.

  1. Expose a callback to create custom drag ghost for the igxDrag.

This alternative would not be related to the igxGrid. If the dev wants to apply draggable on an element and provide a custom drag ghost, then they would also be responsible for showing to the end-user that the specific element is draggable.

The dev can handle multiple elements to be dragged simultaneously, as the whole UI and UX would be a custom definition of the dev.

Let me know which alternative seems better? If dragging and dropping multiple records is a must, then alternative 1 should be reconsidered to include this.

kdinev avatar Feb 25 '19 09:02 kdinev

Hi @kdinev @SlavUI I just updated in the section "Is your feature request related to a problem? Please describe." above, would be more understandable to know the scenario I want to achieve. Thanks, Paul

pnishimura avatar Feb 25 '19 09:02 pnishimura

Hi @kdinev @SlavUI I just updated in the section "Is your feature request related to a problem? Please describe." above.

I do not need to drag and drop multiple rows simultaneously.

pnishimura avatar Feb 26 '19 01:02 pnishimura

@pnishimura Post 7.2.0 we will get @StefanIvanov and @DaniMarinov engaged in producing a design for alternative 1.

kdinev avatar Feb 26 '19 08:02 kdinev

Hi @pnishimura to understand a little better, you basically want to drag a record from a grid to another surface passing the record information to that receiving surface, whatever it is. Two questions arise:

  1. Is the user required to select the row beforehand
  2. We are passing the row object and our clients' developers are responsible what to do with the record data e.g. how to handle / render it

I think it will also help a lot if you are able to provide a specific business case in order for us to understand the context in which such a functionality is needed.

StefanIvanov avatar Feb 26 '19 08:02 StefanIvanov

@StefanIvanov I am writing the response on behalf of @pnishimura.

  1. Is the user required to select the row beforehand

--> No. It is not required to select in order to drag a row.

  1. We are passing the row object and our clients' developers are responsible what to do with the record data e.g. how to handle / render it

--> I expect the behavior as you describe.

If you have any question with this, please let me know.

ymita avatar Mar 05 '19 06:03 ymita

Thank you @ymita and @pnishimura in that case I am sharing with you a design proposal that has been discussed internally and for the moment seems like a viable solution, please provide your feedback as well. row drag 1. The grid when the feature is enabled before any user interaction 2. The user has pressed down on the row drag icon in the beginning of the row and performed a small drag to the right 3. Upon dragging if the area below the cursor supports drop of the row the row icon will change to reflect that it is a valid operation that can be executed

StefanIvanov avatar Mar 05 '19 08:03 StefanIvanov

Hi @StefanIvanov Sorry, I missed your comment above. Your design proposal looks good to me!

@ymita @tkiryu Could you give us your comment on the design proposal above?

pnishimura avatar Mar 22 '19 09:03 pnishimura

Also check out the spec

StefanIvanov avatar Apr 01 '19 12:04 StefanIvanov

Overall, it looks good. There is one thing to add. As a scenario, I would want to drag row itself. In that case, I would add a pseudo element after the row drag icon.

ymita avatar Apr 08 '19 02:04 ymita