Slow addition of GridViewDataColumn in code behind, after RadGridView is loaded

0 Answers 77 Views
GridView
Radek
Top achievements
Rank 1
Radek asked on 24 Jun 2022, 12:05 PM | edited on 24 Jun 2022, 12:30 PM

Hi,

I use RadGridView component, that I want to clean and reuse with different data in code behind (for example by clicking on button).
So what am I doing is calling a clear on all Columns (RadGridView.Columns.Clear()) and then I will start adding new columns for different data.

But the problem is when I use it with GridViewColumnGroup the clearing or adding new Columns takes an long time (seconds or minutes for test example where I have 500 Columns and 50 ColumnGroups).
Even if I add ColumnGroups before adding Columns, it will only slightly improve the situation. 

This slow processing occurs only after component has been displayed at least once. If the component was not already loaded (shown) it takes almost no time.

I tried hidding component before this process, or unsetting ItemsSource, but nothing helped.

Thank you for any help.

Edit:
I added image of Callstack, when i call Clear() method on Columns:

Martin Ivanov
Telerik team
commented on 29 Jun 2022, 10:33 AM

I've tested this, but on my side it took between 3 and 4 seconds to replace the columns. Can you check the project and let me know if I am missing anything? Also, you can take a look at the performance tips and tricks article in the help documentation.
Radek
Top achievements
Rank 1
commented on 30 Jun 2022, 07:54 AM | edited

Hi, thank you for sending testing application. The main slowdown occurs when I set EnableColumnGroupsVirtualization to "False" and have frozenColumns. Then the clearing adding new columns is very slow.

I had to turn off ColumnGroupsVirtualization because of one bug which occurs when i have fixedColumns which are not visible (IsVisible="False"):

Please, see Annex, where i changed your App.xaml.cs little bit (added 4 rows of code).

Likely solutions:
1. To use ColumnGroupVirtualization, I would have to probably shift unvisible columns after frozen columns.
2. With ColumnGroupVirtualization off, I would have to set FrozenColumnCount to 0, before clearing columns and then set it back. With this one, there is no significant slowdown

Thank you for your help.

Martin Ivanov
Telerik team
commented on 04 Jul 2022, 12:41 PM

Indeed, disabling the UI virtualization has a significant impact on the performance. This means that all associated visual elements will be generated which is slow operation. The solutions you shared seem okay to me, for the described scenario.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Radek
Top achievements
Rank 1
Share this question
or