Prevent GridView From Sorting Until Row Changes Are Complete

4 posts, 0 answers
  1. Susan
    Susan avatar
    8 posts
    Member since:
    Jun 2014

    Posted 01 Feb 2018 Link to this post

    My gridview datasource is only updated when all row changes are complete; however, when a cell in a sorted column is changed, the grid is sorted immediately so the changing row may move positions.  This can be confusing to the user.  How can I prevent the grid from resorting until after the row changes are complete?

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4004 posts

    Posted 02 Feb 2018 Link to this post

    Hello, Susan,

    Thank you for writing.  

    When a certain column is sorted, all rows should be ordered according to the sort criterion. That is why after changing the sorted cell value, it will lead to positioning the row on its correct place. This is desired behavior so far. Could you please share with me what behavior you would find suitable for this scenario? 

    Note that RadGridView supports custom sorting behavior. Thus, you can fully control how the rows are ordered. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/sorting/custom-sorting

    I hope this information helps. Should you have further questions I would be glad to help. 
     
     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Susan
    Susan avatar
    8 posts
    Member since:
    Jun 2014

    Posted 02 Feb 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    The desired behavior would be for the grid to be considered in edit mode until the data is updated in the underlying source and for the grid to not be sorted while it is edit mode.

    Or, restated, when a user starts editing a row, sorting is not done until the user finishes editing that row and the data is either saved or the update is cancelled.

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4004 posts

    Posted 02 Feb 2018 Link to this post

    Hello, Susan,  

    Thank you for writing back. 

    Let me please explain in details how the editing mechanism in RadGridView works. By default, no editor is available in the grid. If you double click a cell or press F2 when a certain cell is selected, RadGridView activates the relevant editor for that cell and RadGridView enters edit mode. After you enter the desired value in the editor you can commit the value by pressing the Enter key or navigate to another cell. Pressing the Escape key will cancel the edit operation. Note that once the editor's value is committed, the underlying DataBoundItem is updated accordingly. This is the designed behavior. Have in mind that once the grid is sorted by a certain column, it orders the rows considering the applied SortDescriptor and the cells' values belonging to this column. 

    One possible solution is to use the already suggested custom sorting functionality where you can fully manage how the rows are ordered. Alternatively, RadGridView allows you to prevent the built-in data sorting operation but keep the sorting life cycle as it is, e.g. UI indication, SortDescriptors and events remain. This is controlled by the MasterTemplate.DataView.BypassSort property which default value is false. This means that RadGridView won't perform the sorting if you set it to true. This may be suitable for cases in which you bound the grid to a DataTable and you want to apply the sort direction to the DataTable, not to the grid itself. A sample code snippet is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/sorting/basic-sorting 

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top