This is a migrated thread and some comments may be shown as answers.

Force a RadGridView to load data even if it is not visible

4 Answers 279 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nicola Tramarin
Top achievements
Rank 1
Nicola Tramarin asked on 27 Nov 2014, 01:14 PM
Hi,
I have a RadTabControl with several tab items, and a RadGridView inside each TabItem, with its ItemsSource binded to a specific collection of data.
Of course the data of those RadGridViews is loaded only when the containing tabitem is selected at least once, and the gridview is shown at least once.

My problem is that I need to export the data of all those RadGridViews (using Export() method), whether they have been selected by the user or not.
By now I may export data only of those grid that have been shown at least once, the others don't contain any data.

So the question is:
Is there a way to force a RadGridView to load its data without showing it, (in my case without manually selecting the RadTabItem that contains the grid)?

Thank you very much for your kind attention

Enrico

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 28 Nov 2014, 11:09 AM
Hi Enrico,

I am afraid RadGridView will not load the bound data and then export it until it is actually realized. You can check the Export Support article, especially the section Export through RadDocument, for more information on different options.

Hopefully this can give you some ideas.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Chris
Top achievements
Rank 1
answered on 24 Jun 2019, 03:07 PM

Im experiencing this very issue where RadGridView's on other RadTabItems are not exported because they have not been "seen". The answer from Dimitrina only leads to articels about exporting not what we can do to actually export data that is in memory but hasnt been rendered in the control.

Is there a technique which will force a RadGridView to render data in situation like mine and Nicola's?

0
Martin Ivanov
Telerik team
answered on 27 Jun 2019, 09:43 AM
Hello Chris,

To force rendering of the gridview control you can call its Measure, Arrange and UpdateLayout methods manually after you create it and set its ItemsSource. Here is an example in code that can be used with most UI elements in WPF:
private static void PrepareForExport(FrameworkElement element)
{
    if (element.ActualWidth == 0 && element.ActualHeight == 0)
    {
        double width = element.Width > 0 ? element.Width : 500;
        double height = element.Height > 0 ? element.Height : 300;
        element.Measure(Size.Empty);
        element.Measure(new Size(width, height));
        element.Arrange(new Rect(0, 0, width, height));
        element.UpdateLayout();
    }
}
You can also check the Export section in the RadGridView documentation to see the different export options.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Chris
Top achievements
Rank 1
answered on 28 Jun 2019, 02:25 PM

Well thats a lesson i will not forget. Seems obvious now but...

Regarding export options, and perhaps im wrong, i really didnt see that would get me what i needed. I believe setting any additional options wouldnt have mattered since the RadGridView hadnt been created yet.

Thank Martin!

Tags
GridView
Asked by
Nicola Tramarin
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Chris
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or