Skip to main content

ReportDesignerClientSideModelGenerator.GetJsonModelScript(ReportDesignerModel) Method

Generates a client-side Report Designer model based on specified data and serializes this model to Json.

Namespace: DevExpress.XtraReports.Web.ReportDesigner

Assembly: DevExpress.XtraReports.v24.1.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

Declaration

public string GetJsonModelScript(
    ReportDesignerModel reportDesignerModel
)

Parameters

Name Type Description
reportDesignerModel ReportDesignerModel

A client-side Report Designer model.

Returns

Type Description
String

A string that is a serialized Report Designer model.

Example

The following code implements the controller action and returns the Report Designer model. For more information on Report Designer server-side configuration, refer to the following help topic: Report Designer Server-Side Configuration (ASP.NET MVC).

The GetModel method obtains a client-side model and sets the ASPxReportDesigner.AllowMDI property to false. The GetJsonModelScript method serializes the model to JSON. The model is subsequently sent to the client.

using DevExpress.Web.Mvc.Controllers;
using DevExpress.XtraReports.Web.ReportDesigner;
using System.Web.Mvc;
// ...
  public ActionResult GetReportDesignerModel(string reportUrl)
  {
      Response.AppendHeader("Access-Control-Allow-Origin", "*");

      var generator = new ReportDesignerClientSideModelGenerator();
      var model = generator.GetModel(
              reportUrl,
              // A report that the Report Designer loads when the application starts.
              GetAvailableDataSources(),
              // Data sources available in the Report Designer.
              "ReportDesigner/Invoke",
              // Controller action that processes Report Designer requests.
              "WebDocumentViewer/Invoke",
              // Controller action that processes Web Document Viewer requests.
              "QueryBuilder/Invoke"      
              // Controller action that processes Query Builder requests.
          );
      model.AllowMDI = false;
      var modelJsonScript = generator.GetJsonModelScript(model);    
      return Content(modelJsonScript, "application/json");
  }
See Also