using DevExpress.Blazor.Reporting; using DevExpress.DataAccess; using DevExpress.DataAccess.Json; using DevExpress.XtraReports.UI; using Microsoft.AspNetCore.Components; using TestDevExpress.Components.Reports; namespace TestDevExpress.Components.Pages { public partial class ReportViewer { // Recupera il parametro "id" dalla Query String (?id=7) [SupplyParameterFromQuery(Name = "id")] public int? OfferId { get; set; } // Variabile che conterrā l'istanza del report DevExpress public XtraReport OfferReportInstance { get; set; } private DxReportViewer? reportViewer; private TestReport Report = new TestReport(); private OffertReport offertReport = new(); //private int IDOffert = 10283; protected override void OnInitialized() { // Create a new JSON source. var jsonSource = new UriJsonSource() { Uri = new Uri(@"https://iis01.egalware.com/Lux/SRV/api/Report/Offert") }; // Create the "id" path parameters that are appended to the JSON URI jsonSource.PathParameters.AddRange(new[] { new PathParameter("id", typeof(int), new Expression("?ID")) }); // Assign the JSON source to the data source. var datasource = new JsonDataSource() { JsonSource = jsonSource }; offertReport.DataSource = datasource; //// Imposta il parametro PRIMA che il viewer renderizzi //Report.Parameters["orderID"].Value = IDOffert; //Report.Parameters["orderID"].Visible = false; } protected override void OnParametersSet() { base.OnParametersSet(); // Inizializza la classe del tuo report (creata con il designer DevExpress) OfferReportInstance = new TestReport(); // Verifica se il parametro č stato passato nell'URL if (OfferId.HasValue) { // Cerca il parametro all'interno del report DevExpress (assicurati che il nome corrisponda) var parametroDx = OfferReportInstance.Parameters["offerID"]; if (parametroDx != null) { // Assegna il valore recuperato dall'URL parametroDx.Value = OfferId.Value; // (Opzionale) Nascondi il parametro nell'interfaccia utente se non vuoi che l'utente lo modifichi parametroDx.Visible = false; } } else { // Cerca il parametro all'interno del report DevExpress (assicurati che il nome corrisponda) var parametroDx = OfferReportInstance.Parameters["offerID"]; if (parametroDx != null) { // Assegna il valore recuperato dall'URL parametroDx.Value = 7; // (Opzionale) Nascondi il parametro nell'interfaccia utente se non vuoi che l'utente lo modifichi parametroDx.Visible = false; } } } } }