Suspend sorting data is pasted

2 posts, 0 answers
  1. Huy
    Huy avatar
    10 posts
    Member since:
    Jul 2014

    Posted 17 Sep 2014 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 Sep 2014 Link to this post

    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.
     
Back to Top