GridView performance in self referencing hierarchy mode

1 Answer 30 Views
GridView
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Marian asked on 17 May 2024, 11:31 AM

Hello,
I have problem with performance of GridView in self referencing hierarchy mode. I am working on move up/down function to move specific row up or down. I need to move it also in my underlying list, so I move it first in my list and then clear BindingList for GridView and add new items. This is done in DoRefreshEditorItems method of TestParEditorCollection class:

		private void DoRefreshEditorItems()
		{
			EditorItems.Clear();
			maxGridId = 0;

			foreach (var item in Items)
			{
				var editorItem = new TestParEditorItem(item, ++maxGridId);
				EditorItems.Add(editorItem);

				if (item.HasSubItems)
					AttachSubItems(editorItem);
			}

			RenumberRows();
		}

Each call to EditorItems.Add() takes cca 100ms and whole refresh of 20 rows takes cca 2s. It looks like this:

I also tried to set DataSource to null, refresh binding list and set DataSource back, but it looks very similar. I have attached test project, it's TelerikTestReal project in solution.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 22 May 2024, 10:27 AM

Hello Marian,

I appreciate the provided details.

Each operation executed on the bound collection will be reflected in the UI. What you can do is suspend the UI updates by using the Begin/EndUpdate() methods of the control. You can wrap the logic between these two methods.

private void tsEditUp_Click(object sender, EventArgs e)
{
	this.radGridView1.BeginUpdate();
 .... custom logic
        this.radGridView1.EndUpdate();
}

private void tsEditDown_Click(object sender, EventArgs e)
{
    this.radGridView1.BeginUpdate();
 . . . .  custom logic
    this.radGridView1.EndUpdate();
}

This way the row re-position will be faster.

Regards,
Dinko | Tech Support Engineer
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.

Marian
Top achievements
Rank 2
Iron
Iron
Iron
commented on 06 Jun 2024, 12:58 PM

Hello,

thanks, yes, it's faster. So is it generally expected to wrap each data update between BeginUpdate/EndUpdate? Because it's seems to be very slow for me, to take 100ms for each added row? What if I will have 100k rows, not only 20?

Dinko | Tech Support Engineer
Telerik team
commented on 07 Jun 2024, 11:07 AM

It is recommended to wrap the code by performing a large number of updates targeting the data between BeginUpdate/EndUpdate. By default, each update triggers the UI. Using these methods will suspend the UI updates. After the EndUpdate, the UI updates will be triggered for all items at once, thus improving the performance.
Tags
GridView
Asked by
Marian
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or