RadGridView - sorting performance

1 Answer 123 Views
GridView
Daniel
Top achievements
Rank 2
Iron
Iron
Daniel asked on 06 Mar 2023, 12:52 PM

Hi Telerik support team,

I've performance issues with sorting in a radGridView. Below you find a very simple example (grid with 2 text columns) and nothing specials. The dataset (deserialized from a json file) contains 7560 rows, which is not much. 

My own conclusion is 'it depends on the data'. In my dataset the column PhaseName is sorting ok. ProjectName is very slow. When I group the columns I see that ProjectName has not much groups (so a lot of duplicates) and PhaseName has a lot of groups (so, not much duplicates).

I tried to fasten it up with custom sorting but I got the same result. Can you help me with this issue??

(by the way: grouping also takes a lot of time)

Code:


    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();

            radGridView1.Columns.Add(new GridViewTextBoxColumn("ProjectName") { ReadOnly = true });
            radGridView1.Columns.Add(new GridViewTextBoxColumn("PhaseName") { ReadOnly = true });

            LoadData();
        }

        private void LoadData()
        {
            var json = File.ReadAllText(@"c:\Daniel\content.json");

            var list = JsonConvert.DeserializeObject<List<ProdTemp>>(json);
            radGridView1.DataSource = list;
        }

        internal class ProdTemp
        {
            public string ProjectName { get; set; }
            public string PhaseName { get; set; }
        }
    }

 

Regards,

Daniel Kaya

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Mar 2023, 06:35 AM

Hello, Daniel,

By default, if the rows count is less than 10 000 we use quick sort to order the items. If there are more items we use Red-Black tree. This is controlled by the UseHybridIndex property. Thus, depending on the actual data you have, the performance may be different because the two sorting algorithms are effective with different data. I have created a sampel project and tested the sorting behavior and it seems to be significantly improved with the following setting:

     (radGridView1.MasterTemplate.ListSource.CollectionView as GridDataView).UseHybridIndex = false;

An alternative approach is using a custom comparer. A sample approach is demonstrated in the following KB article:

https://docs.telerik.com/devtools/winforms/knowledge-base/use-custom-comparer-to-speed-up-the-sorting-in-radgridview 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Daniel
Top achievements
Rank 2
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or