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

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

3 Answers 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SeungHak
Top achievements
Rank 1
SeungHak asked on 12 Jan 2018, 03:52 AM

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.

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Jan 2018, 11:08 AM
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.
0
SeungHak
Top achievements
Rank 1
answered on 15 Jan 2018, 09:25 AM

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

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Jan 2018, 09:39 AM
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.
Tags
GridView
Asked by
SeungHak
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
SeungHak
Top achievements
Rank 1
Share this question
or