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

Suspend sorting data is pasted

1 Answer 104 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Huy
Top achievements
Rank 1
Huy asked on 17 Sep 2014, 09:51 PM
I have exactly the same problem as described here

http://www.telerik.com/forums/suspend-sorting-during-paste

Basically I want to disable column sorting when users wants to paste their data into the grid
Just let the column unsorted and let user decide whether they want to sort again

I tried this on Pasting event of the grid, but it doesn't work
private void OnGridPasting(object sender, GridViewClipboardEventArgs e)
{
    ((RadGridView) sender).CurrentColumn.SortingState = SortingState.None;
}
It actually doing nothing, the column still get sorted on pasting, and I can see the sorting caret on the column header, which is weird !!

So I switched to PastingCellClipboardContent event and do this
private void OnPastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e)
{
    e.Cell.Column.SortingState = SortingState.None;
}
The sorting caret on column header disappears, but as the data being modified, they still get sorted <-- I believe this is a bug

What else can I do to get my problem solved?

Thanks

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 22 Sep 2014, 12:40 PM
Hello,

I attached a demo solution to illustrate how you can save the current sort configuration and then clear it just before pasting the data and add it back after the pasting has finished. 

Basically, the reply posted by my colleague Rossen Hristov in the referred topic still applies. Keep in mind a SortDescriptor will be evaluated and the data will be sorted accordingly once it is added to the SortDescriptors collection.

Regards,
Dimitrina
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Huy
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or