Get every cells in a GridView

2 Answers 95 Views
GridView
minh
Top achievements
Rank 2
Iron
Iron
Iron
minh asked on 16 Jul 2021, 09:07 AM

Hi Telerik team

I would like to go through every cell in a RadGridView to get the value, foreground and background of each cell.

Do you have any solution for that?

For your information, I tried  gridView.ItemContainerGenerator.ContainerFromItem() but it work only for the current view port but I need all pages.

 

Many thanks for your support,

 

Stenly
Telerik team
commented on 16 Jul 2021, 02:57 PM

Hi Minh,

Could you please specify why do you need the Background and Foreground properties of each cell? So we can try to provide a solution for your issue.

minh
Top achievements
Rank 2
Iron
Iron
Iron
commented on 16 Jul 2021, 11:07 PM | edited

Hi Stanley,

Thank for your prompt reply.

In fact, I have a financial grid where some cells have specific foreground and background colors. I need develop a print preview of the grid and keep all the current grid view properties such as colors of cells, width of cells, alternative row colors, number format in cell etc…

I tried use the default print preview of telerik but the result is very far from what we expected, because the grid is quite complex with alot of business rules to be considered. I finaly chose export to excel way where I can freely custom the preview as I want based on the current view of grid. That’s why I need to know the colors of every cell in the current grid.

Many thanks,

Minh

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Stenly
Telerik team
answered on 21 Jul 2021, 02:09 PM

Hi Minh,

WPF uses UI virtualization which renders rows that are only visible on the window. This prevents you from reading all of the rows in the grid. Please refer to the following documentation regarding the UI virtualization:

WPF DataGrid | UI Virtualization | Telerik UI for WPF

The UI virtualization could be disabled, then all the visual elements will be loaded once RadGridView is visualized and its items are populated.

Please note, however, that this can lead to huge performance issues and additional loading time, and thus - disabling the virtualization when dealing with large amounts of data is highly not recommended.

What I can suggest is to instead work with the underlying data items and style the exported Excel document as explained in this article. Please let me know if you would find this applicable.

Regards,
Stenly
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/.

0
minh
Top achievements
Rank 2
Iron
Iron
Iron
answered on 23 Jul 2021, 03:41 AM

Hi Stanley,

Many thanks for your reply. Yes, you're completely right on UI virtualization. I had tried to disable Virtualization and my grid is extremely slow on loading :-(.

Regarding to your suggestion, it's still missing background color of cell and also the look is quite far of our expectation. However, we found an alternative way to preview and I'm going to close this post.

 

Many thanks for your supports.  

Tags
GridView
Asked by
minh
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stenly
Telerik team
minh
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or