Unplanned
Last Updated: 01 Aug 2022 08:45 by ADMIN
Martin
Created on: 30 Jul 2022 15:29
Category: UI for WinForms
Type: Bug Report
0
RadGridView: HybridIndex<T>.PerformWithQuickSort or PerformWithBinaryTree called after row has been deleted.

Repro-steps

  1. Create a RadGridView
  2. Fill it with 8000 rows
  3. Select all rows
  4. Delete all rows and measure the time
  5. Repopulate the same grid with the same 8000 rows
  6. Sort on a column
  7. Select all rows
  8. Delete all rows and measure the time

Expected behavior

  • Both measured times are the same

Observed behavior

  • Deleting rows when a column is sorted take muuuuuuuuch more time

The problem is, after each (!!!) deleted row (not after all deleted rows) the sort-routine kicks in. Sorting all remaining rows. That is 7999 times to many.

One can argue that sorting after deleting something is not required at alle, since the order of the remaining rows (in this case none, but in one cases maybe more) will never change.

I also noticed a HybridIndex is used, possibly to increase performance during adding. Somehow it might hinder performance during deleting stuff.

1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 01 Aug 2022 08:45

Hello, Martin,

I was able to observe the slow rows removing when grid is sorted by a column. These are the performed steps:

1. Sort one of the columns

2. Press Ctrl+A to select all rows

3. Press Delete

        private void FillGrid()
        {
            this.radGridView1.Rows.Clear();
            this.radGridView1.Columns.Clear();

            this.radGridView1.Columns.Add("Id");
            this.radGridView1.Columns.Add("Name");
            this.radGridView1.BeginUpdate();
            for (int i = 0; i < 8000; i++)
            {
                this.radGridView1.Rows.Add(i, "Item" + i);
            }
            this.radGridView1.EndUpdate();
            this.radGridView1.MultiSelect = true;
        }

The attached gif file illustrates the difference in the required time for deleting the rows when there is a sorted column. 

I have approved this bug report. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to handle the Delete key and remove the applied sorting before deleting the rows: 

            BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior;
            gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
            gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior());
        public class CustomGridDataRowBehavior : GridDataRowBehavior
        {
            protected override bool ProcessDeleteKey(KeyEventArgs keys)
            {
                this.GridControl.SortDescriptors.Clear();
                return base.ProcessDeleteKey(keys);
            }
        }

I hope this helps.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.