內置組件說明
以下是對 中包含的組件的描述FastReport.Web。我們不建議使用除 之外的組件WebReportContainer,因為它們在標準組件樹之外可能不穩定。
但是,要微調渲染,您可能需要使用其他組件。
-
Web報表容器
執行渲染的主要且最通用的 Blazor 組件WebReport是<WebReportContainer/>. 它位于命名空間中FastReport.Web.Blazor.Components。
它采用的唯一參數是該類的對象WebReport。這意味著要使用該組件,您必須創建該類的一個對象WebReport,為其分配一個Report以及其他必要的參數,并將該對象傳遞給參數WebReportContainer。
例子<WebReportContainer WebReport="@UserWebReport" /> @code { public WebReport UserWebReport { get; set; } protected override void OnParametersSet() { var report = Report.FromFile( Path.Combine( directory, "My report.frx")); // Registers the application dataset Report.RegisterData(DataSet, "NorthWind"); UserWebReport = new WebReport(); UserWebReport.Report = Report; } }
點擊復制
該組件可以定義不同的模式(設計器、對話框和普通預覽),并可以準備報告、嵌入默認樣式和單獨樣式、顯示工具欄、大綱和選項卡、處理交互式報告等。
-
網絡報告預覽
它與前面的組件類似,但沒有考慮設計器模式。也就是說,它總是嘗試準備并提交報告。
-
報告容器
它與之前的組件類似,但不包括加載WebReport樣式(工具欄/選項卡/大綱的通用和單獨)。
它負責報告的準備以及隨后與工具欄和選項卡(如果需要)一起顯示。
當使用任何交互性(單擊報告/使用對話框表單)時,更新的是該組件。
-
報表主體/導出組件
調用ReportBody大綱呈現(如果需要)并“嵌套”一個組件,該組件是報表本身的呈現 ( ,并將其ReportContainer傳遞給它。不建議使用。
-
Blazor導出
組件的“最低”級別根本不是組件,而是其本身 - 用于將準備好的報告導出為BlazorExport構建格式的工具。位于命名空間中。FastReport.Web.Blazor.Export
要構建此導出,您必須:
- 準備報告;
- 確保此報告不使用對話框表單(它們是使用 呈現的,DialogPageComponent并且不在本教程中介紹);
- 創建自己的組件并在其中顯式定義構造方法(調用方法的重寫BuildRenderTree);
- 在此構建方法中,創建一個BlazorExport實例,設置其所需的屬性,然后調用 Export 并傳遞以下參數:一個 Report 和一個構建器實例(該實例是此重寫方法的參數)。
/// Main function protected override void BuildRenderTree(RenderTreeBuilder builder) { using (BlazorExport blazor = new BlazorExport()) { blazor.StylePrefix = $"fr{WebReport.ID}"; blazor.EmbedPictures = true; blazor.OnClick += ProcessClick; blazor.EnableMargins = WebReport.EnableMargins; blazor.SinglePage = true; blazor.CurPage = WebReport.CurrentPageIndex; blazor.Export(myReport, builder); } }
點擊復制
-
在線設計師
目前,Online Designer 可以使用 javascript 在 iframe 元素中工作,并且與 Core 的 Online Designer 程序集完全兼容。
要僅使用設計器的功能,您可以調用該<IFrameDesigner/>組件,并向其傳遞WebReport帶有配置的 Report 屬性和可選的DesignerLocaleand 的參數DesignerPath:
<IFrameDesigner WebReport="CurrentWebReport" />
點擊復制