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

Suspend sorting during paste

3 Answers 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry Foster
Top achievements
Rank 1
Terry Foster asked on 30 Aug 2011, 04:13 PM
Hi,

We're currently having an issue where when the user pastes multiple cell values in a column that is currently sorted, unexpected things can happen depending on the values involved.  Specifically, if you have two items in a grid with a text column that is sorted, like this:

Item1
Item2

and you paste the following values over those two cells:

Item3
Item4

only one of the items ends up getting pasted, due to the following sequence of events:

- Paste 'Item3' over 'Item1'
- Result:
Item3
Item2

- Sort column
- Result:
Item2
Item3

- Paste 'Item4' over 'Item3'
- Result:
Item2
Item4

This is obviously not what the user would expect or want.  If we could suspend sorting until the pasting is finished, that would seem to solve the issue, but I can't seem to find a way to do this.  Can you suggest something?

Thanks,
Terry

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 31 Aug 2011, 07:50 AM
Hi Terry,

You can save your current sort just before pasting, clear the grid sorting and restore it when needed. 

Kind regards,
Vlad
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Terry Foster
Top achievements
Rank 1
answered on 31 Aug 2011, 01:38 PM
Hi Vlad,

Won't clearing the sort potentially change the order of the rows in the grid, and cause essentially the same problem (i.e., values not pasted where the user expects)?

Terry
0
Rossen Hristov
Telerik team
answered on 06 Sep 2011, 08:41 AM
Hello Terry Foster,

I will do my best to explain how sorting works.

When there is sorting it takes precedence over everything else. In other words, if the user is allowed to paste his items anywhere, then after pasting them the view of the grid would be left in an inconsistent state. When the grid is sorted, the items that are displayed in it should always be sorted in the correct order. What this means that it does not really matter where the user pastes them -- if that is not their place they will be moved to the correct place. So you have to decide who will be responsible for the order of items displayed of the grid -- either RadGridView will sort them and make sure they appear in the correct order, or you will leave RadGrid View unsorted and then the user will be the one that can command what goes where.

If you turn off the sorting, let the user paste several items, and then turn on the sorting again -- the grid will sort them according to the sort criteria thus overriding what the user wants. You just can't mix the grid sorting with user desires -- the grid is either sorted correctly or it is not sorted at all.

To make a long story short -- RadGridView is either sorted as it decides or it is not sorted at all. There is not intermediate state of being half-sorted.

I hope this explains the matter a little bit better. Let me know if you have any other questions.

Kind regards,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
Terry Foster
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Terry Foster
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or