This is a migrated thread and some comments may be shown as answers.

Adjust column cells after drag/drop

4 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gabriela
Top achievements
Rank 1
Gabriela asked on 21 Apr 2011, 02:44 PM
I have an application that uses the drag/drop feature of gridview.  When a cell is dragged from one column onto another, I need the cells from the draggedCell column to shift up, filling in the cell that has been dragged to another column.

I also need the column onto which the cell was dropped to shift downward thereby allowing the dropped cell to be inserted at the row position at which it was dropped.

Thanks for any help and code examples you can provide.

4 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 27 Apr 2011, 10:45 AM
Hello Gabriela,

Thank you for your question.

From the description you have given I understand your scenario in the following way - when you drag a cell from one column and drop it in other column:

1. Every cell from the first column, located after the dragged cell, should accept the value of the cell from the next row. Should the cell from the last row get empty?
2. Every cell from the second column, located after the dropped cell, should accept the value of the cell from the previous row. Should the value of the last cell get lost?

One more question is what is the expected behavior when a cell is dropped in a different row of the same column?

I am looking forward to your reply.

Best regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gabriela
Top achievements
Rank 1
answered on 27 Apr 2011, 01:26 PM
Dear Alexander,

Thanks for your quick response.  To answer your questions -

1. Correct.  Every cell from the first column including the cell position that was dragged, should accept the value of the cell from the next row.  The cell from the last row having shifted up will leave the cell that was at that last position empty.

2. Correct.  Every cell from the second column, located after the dropped cell, should accept the value of the cell from the previous row.  The last cell should not get lost, it will either move into the cell directly below it, or if there are no more rows available in the grid, a new row should be inserted and then the cell in the new row will be filled with the cell from the previous row.

Other question - If a cell is dropped from one row to another higher (above) row in the same column, all rows below where the cell is dropped should shift downward taking on the value of the cell directly above.  However, if the cell that was dragged is not the last one in the column, cells below the dragged cell should remain as they are.  On the other hand, if a cell is dragged below other cells in the same column, cells directly below the dragged cell should shift upward taking on the value of the cell directly below.

So to summarize, I would like the grid to work so that any time a cell is dropped onto another cell, all cells below the target cell shift downward to make a "hole" for the new value to be inserted.   And where a "hole" is left by having dragged a cell, all cells below that one should shift upwards to fill in the "hole".  Hope this makes sense.

Thanks,
0
Accepted
Alexander
Telerik team
answered on 02 May 2011, 08:58 AM
Hello Gabriela,

Thank you for the provided additional details regarding your scenario. I have attached a sample project here to demonstrate a solution for it. The logic for shifting cell values is implemented in the PreviewDragDrop event handler of RadDragDropService.

I hope it helps.

Best regards,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gabriela
Top achievements
Rank 1
answered on 03 May 2011, 02:15 PM
Thank you for your help and example application!
Tags
GridView
Asked by
Gabriela
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Gabriela
Top achievements
Rank 1
Share this question
or