A NativeScript plugin for easy access to Telerik Rporting REST API.
Run the following command from the root of your project:
tns plugin add nativescript-telerik-reporting
This command automatically installs the necessary files, as well as stores nativescript-telerik-reporting as a dependency in your project's package.json file.
There is no additional configuration needed!
Creates a reporting client instance with the given
serverUrl. Note this should be the root of your site where you host the REST service and should not include
Also you can send
additionalHeaderswhich will be sent with every request. Useful for sending authentication in case your reporting service requires authentication.
- getAvailableDocumentFormats(): Promise<DocumentFormat>
Gets an array of supported document export formats by the server. This method can be called without registering the client. (API Reference)
- register(): Promise
Registers the client with the server. (API Reference)
- unregister(): Promise
Unregisters the client from the servers. You need to call this once you finished using the reporting client so it can free up resources on the server. (API Reference)
- getReportParameters(ReportSource): Promise<ReportParameter>
Gets info about the parameters for the given reports. Also can be used to check the validity of the given parameters for the given report. (API Reference)
- createInstance(ReportSource): Promise
ReportingInstancethat can be used to render and download reports from the server. (API Reference)
- createDocument(DocumentFormatKey): Promise
ReportingDocumentwith the given export format. (API Reference)
- destroy(): Promise
Destroys the reporting instance from the server. It is important to call this method once you finish your work so it can free the resources on the server. (API Reference)
- getInfo(): Promise
Gets info about the rendered report document, for example if it is ready on the server, how many pages it has, etc.(API Reference
- download(File?): Promise
Downloads the prepared document from the server. By default it names the file with
documentIdadds an appropriate extension and saves the file in the device specific temp folder. In case you need to save the file somewhere else, or need to name it differently you can send a
Fileinstance to this method.
- getPage(number): Promise
Gets information about the given page. (API Reference)
- destroy(): Promise
Destroys the reporting document from the server. It is important to call this method once you finish your work so it can free the resources on the server. (API Reference)
A typical usage scenario is when you want to generate a report on your server and the download the file in an appropriate format (for example a PDF document). Below is an example how you can make this. You start by creating a client with your server's URL. Then you register your client, create an instance and a document. Finally you download the document to the mobile device.
It is really important to remember to call
destroy() for your instances and documents and to
unregister() your client as this frees up resources on the server. Also it is a good idea to reuse clients/instances whenever possible.
This repository plain NativeScript demo. In order to run those execute the following in your shell:
$ git clone https://github.com/peterstaev/nativescript-telerik-reporting$ cd nativescript-telerik-reporting$ npm install$ npm run demo-ios
This will run the plain NativeScript demo project on iOS. If you want to run it on Android simply use the
-android instead of the