How do I get the sorted gridview data by clicking on the gridview header?

4 posts, 0 answers
  1. SeungHak
    SeungHak avatar
    3 posts
    Member since:
    Oct 2015

    Posted 11 Jan 2018 Link to this post

    hi telerik

                    foreach (GridViewDataRowInfo row in re_ItemregiView.Rows)
                    {
                        //
                    }

     

    The gridview data sorted by clicking on the Gridview header. the data from the source above will have the same content but in a different order.

    I want to get an ordered sequence of data on the source.

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

    Posted 12 Jan 2018 Link to this post

    Hello, SeungHak,   

    Thank you for writing.  

    RadGridView exposes two collections that contain data rows:

    - Rows - contains all data rows that belong to RadGridView. Data operations such as grouping, sorting, filtering, etc. do not change the content of the collection or the order in which the row objects exist in the collection.

    - ChildRows - returns the data rows that are currently represented by RadGridView in the order in which they appear. The collection is modified every time a data operation (grouping, sorting, filtering) occurs.

    It is suitable to use the ChildRows collection in your case.

    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. SeungHak
    SeungHak avatar
    3 posts
    Member since:
    Oct 2015

    Posted 15 Jan 2018 Link to this post

    wow.....

    Thanks to that, I solved it well.

    Can I ask you another question?

    When sorting by clicking the header in gridview, the numbers are not aligned correctly.

    For example

    10

    100

    20

    200

    What I want

    10

    20

    100

    200

    help me T.T

     

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

    Posted 15 Jan 2018 Link to this post

    Hello, SeungHak,  

    Thank you for writing back. 

    It seems that you have string data in the column. That is why the cells are ordered alphabetically. It is recommended to use numeric values where they will be ordered by their values in the GridViewDecimalColumn. Alternatively, you can use the custom sorting functionality that RadGridView supports. Thus, you will have full control over the sorting behavior. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/sorting/custom-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