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

Printing grid in loop issue grid data does not refresh

4 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tomas
Top achievements
Rank 2
Veteran
Tomas asked on 13 Jan 2021, 06:23 PM

Hi, I have a loop where I am filling the grid and immediatelly print the grid. All printed documents have the same grid values of the last loaded records to the grid DataSource. Is there something I can do to properly print the grid with correct cell values from actual records?

foreach (var run in _runsToPrint)
{
    FillReportedAnalytesGrid();
    PrintPreview.PrintGrid(rgvReportedAnalytes, run);
}
 private void FillReportedAnalytesGrid()
{
    var records = provider.GetReportedResults();
    rgvReportedAnalytes.DataSource = null;
    rgvReportedAnalytes.DataSource = records;
    rgvReportedAnalytes.BestFitColumns(BestFitColumnMode.AllCells);
    rgvReportedAnalytes.Refresh();
}

 

public static void PrintGrid(RadGridView view, string run)
{
    var document = new RadPrintDocument();
    view.Print(false, document);
}

4 Answers, 1 is accepted

Sort by
0
Tomas
Top achievements
Rank 2
Veteran
answered on 13 Jan 2021, 06:37 PM

I found the issue. It was my fault. I did not properly refreshed the records. I confirm that printed grids look good now. Even BestFitColumns command is applied while it seems on the screen that was not applied.

rgvReportedAnalytes.BestFitColumns(BestFitColumnMode.AllCells);

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Jan 2021, 05:32 AM
Hello, Tomas,   

I am glad that the problem you were facing is now resolved. From a first sight, your code looked OK. 

Please have in mind that it would be greatly appreciated in future if you can provide a sample runnable project demonstrating the undesired behavior that you are facing. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance. Otherwise, we can make only conjectures what causes the issue on your end since it is not clear what is the exact setup that you have according to the provided brief information.  Thank you in advance for your cooperation.

If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
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
Tomas
Top achievements
Rank 2
Veteran
answered on 14 Jan 2021, 09:37 AM

Hello Dess,

I understand, in future I will prepare runnable project. This was quite specific project connected to our company environment, but I could refactor it and prepare some mock classes to generate fake records.

Cheers,

Tomas

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Jan 2021, 09:47 AM

Hello, Tomas,

Thank you for your understanding. Of course, you can use any sample data just to simulate the behavior you are facing. It is not obligatory to provide the original project. Usually, the exact data is not a factor in such cases so you can populate the grid with any dummy data.

Off topic, note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.  

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
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/.

Tags
GridView
Asked by
Tomas
Top achievements
Rank 2
Veteran
Answers by
Tomas
Top achievements
Rank 2
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or