logo
small logo
  • Products
  • Buy
  • Support
  • Articles
  • Forgot password?
    • en
    • ru
    • pt
    • es
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to update the FastReport.Core web report
  • How to hide unnecessary items from the Web Report toolbar

    June 3, 2020

    Most advanced report generators let us generate reports for web applications. When displaying reports to

    read more
  • How to create the invoice from ASP.Net Core application

    August 31, 2020

    Few believed in the success of the new open-source ASP.Net Core framework from Microsoft. It’s

    read more
  • How to use Online Designer in ASP .Net Core

    January 17, 2018

    One of the novelties by FastReport .Net 2018 was the adaptation of OnlineDesigner to the

    read more
  • How to use FastRerport.Core in Vue.js application

    June 30, 2019

    The framework Vue.js is now very popular and is on a par with Angular. We

    read more
  • How to make PDF on Raspberry PI with .NET Core

    May 26, 2020

    Raspberry PI is a miniature single-board computer with ARM processor. This microcomputer is often used

    read more

How to update the FastReport.Core web report

September 21, 2020

Sometimes you need to update the report, for example if you input a new variable value, or if you want to display another report in the same Web report object at all. This usually updates the entire view (we're talking about MVC applications) for the sub-set. But it would be much better if you updated only the Web report object.

1. Update asp.net core report after variable change

https://forum.stimulsoft.com/viewtopic.php?f=13&t=57213

… All this is great and working well. What we cannot figure out is how to refresh the report Variables with this new posted-back data and have the report redraw. Is this done within the Controller and, if so, how do we tell the viewer to refresh (thus getting the new data) or is this done within the View and, if so, what is the correct method to call on the Viewer object. ...

2. How do I refresh a Web Report Viewer After Changing the Report.

https://forum.stimulsoft.com/viewtopic.php?f=13&t=58104

 What is the object of the web report? Basically, it is an html container with a set of scripts that allow you to navigate through the pages of the report and call useful functions, such as printing and exporting. And the web report itself is a report exported to html. The easiest way to update a part of the page is to use iframe. We will only replace the frame source, and it will get a partial or full view of the report by url. Let's consider an example where the web application page displays a drop-down list and a frame. If you select a report name from the drop-down list, the web report object with the corresponding report is loaded.

To start with, we'll need a method in the controller that returns the view with the Web report object:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public IActionResult Update(string SelectedItem)
 {
 if (SelectedItem != null)
 {
 WebReport webReport = new WebReport();
 webReport.Report.Load($"App_Data/{SelectedItem}.frx");
 
 var dataSet = new DataSet();
 dataSet.ReadXml("App_Data/nwind.xml");
 webReport.Report.RegisterData(dataSet, "NorthWind");
 
 webReport.Width = "1000";
 webReport.Height = "1000";
 ViewBag.WebReport = webReport;
 } 
 return PartialView();
 } 

The method has an input parameter SelectedItem - the name of the selected report.

..

For this method you need to create a partial view with a single line of code that displays the web report object:

@await ViewBag.WebReport.Render()

Appearance of the Index start page will look like as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@{
 ViewData["Title"] = "Home Page";
}
 <div> 
 <select onchange="$('#partialViewDiv').attr('src', '/Home/Update?SelectedItem='+this.value)" id="report">
 <option disabled selected>default</option>
 <option>Lines</option>
 <option>Simple list</option>
 <option>Barcode</option> 
 </select>
 </div>
 <table>
 <tr>
 <td>
 <iframe id="partialViewDiv" width="1000" height="1000"></iframe> 
 </td>
 </tr>
 </table>

 First, we display a drop-down list with three available reports on the form. In the onclick list event handler, we assign a source url frame. The url itself contains the path to the web method with the parameter. The value of the parameter is taken from the selected item in the drop-down list. Below, the frame is displayed.

Let's run the application. Select a report from the drop-down list:

Selecting the web report

And will get it:

Updated web report

Thus, partial page refresh by using a frame is very easy to implement.

about product download buy
avatar
Dmitriy Fedyashov
Head of QA
.NET FastReport Core WebReport

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Our team
  • Contact us

© 1998-2021 by Fast Reports Inc.

  • Privacy Policy