Articles in this section
Category / Section

How to Create a Inline JSON Data Source and Dataset in Bold Reports Designer

Published:
Updated:

You can add data for reports in the Bold Report Designer from the application level by initializing the Bold Report Designer. This can be achieved using the addDataSource and addDataSet API methods. With these methods, you can create the data source and dataset for the reports during the initialization of the Bold Report Designer. This is especially useful for non-technical individuals who are unfamiliar with how to connect a database to a report.

Find the following steps to add the Inline JSON data source and dataset for Bold Report Designer from the application.

  • Create a function and bind it with the create API Event in the Index.html file, as shown in the following code sample.
<bold-report-designer id="designer" create="controlInitialized"></bold-report-designer>

<script type="text/javascript">
function controlInitialized(args) {
        ...
       }
</script>
  • Create the datasource object, as shown in the following code sample.
var datasource = {
   __type: 'BoldReports.RDL.DOM.DataSource',
   Name: 'DataSource1',
   Transaction: false,
   DataSourceReference: null,
   SecurityType: 'None',
   ImpersonateUser: false,
   ConnectionProperties: {
     __type: 'BoldReports.RDL.DOM.ConnectionProperties',
     ConnectString: '{\"Data\":\"[\\n  {\\n    \\\"field1\\\": \\\"value1\\\",\\n    \\\"field2\\\": \\\"value2\\\",\\n    \\\"field3\\\": \\\"value3\\\"\\n  },\\n  {\\n    \\\"field1\\\": \\\"value4\\\",\\n    \\\"field2\\\": \\\"value5\\\",\\n    \\\"field3\\\": \\\"value6\\\"\\n  },\\n  {\\n    \\\"field1\\\": \\\"value7\\\",\\n    \\\"field2\\\": \\\"value8\\\",\\n    \\\"field3\\\": \\\"value9\\\"\\n  }\\n]\",\"DataMode\":\"inline\",\"URL\":\"\"}',
     EmbedCredentials: false,
     DataProvider: 'JSON',
     IntegratedSecurity: false,
     UserName: '',
     PassWord: '',
     Prompt: '',
     EmbeddedData: null
   }
 };
  • Create the dataset object, as shown in the following code sample.
var dataset =
 {
   __type: 'BoldReports.RDL.DOM.DataSet',
   Name: 'DataSet1',
   Fields: [
     { __type: "BoldReports.RDL.DOM.Field", Name: "field1", DataField: "field1", Value: null, TypeName: "System.String", UserDefined: false },
     { __type: "BoldReports.RDL.DOM.Field", Name: "field2", DataField: "field2", Value: null, TypeName: "System.String", UserDefined: false },
     { __type: "BoldReports.RDL.DOM.Field", Name: "field3", DataField: "field3", Value: null, TypeName: "System.String", UserDefined: false }
   ],
   Query: {
     __type: "BoldReports.RDL.DOM.Query",
     DataSourceName: "DataSource1",
     CommandType: 0,
     CommandText: "{\"Name\":\"Result\",\"Columns\":[]}",
     QueryParameters: [],
     Timeout: 0,
     QueryDesignerState: null,
   },
   CaseSensitivity: 0,
   Collation: null,
   AccentSensitivity: 0,
   KanatypeSensitivity: 0,
   WidthSensitvity: 0,
   Filters: [],
   SharedDataSet: null,
   InterpretSubtotalsAsDetails: 0,
   DataSetInfo: null,
   DataSetObject: null
 };
  • In the controlInitialized function of the Bold Reports Designer, you can call the addDataSource and addDataSet API methods to create a data source and dataset.
function controlInitialized(args) {
var designerObj = $('#designer').data('boldReportDesigner');
designerObj.addDataSource(datasource);
designerObj.addDataSet(dataset);
}

Reference:

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied