📜 A NativeScript plugin for easy access to Telerik Rporting REST API.
APACHE-2.0 License
This repo only supports NativeScript pre-6.0. The latest version of the plugin supporting NS 6+ is availble as part of ProPlugins.
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!
ReportingClient
serverUrl
. Note this should be the root of your site where you host the REST service and should not include /api/reports
in it.additionalHeaders
which will be sent with every request. Useful for sending authentication in case your reporting service requires authentication.ReportingInstance
that can be used to render and download reports from the server. (API Reference)ReportingInstance
ReportingDocument
with the given export format. (API Reference)ReportingDocument
documentId
adds 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 File
instance to this method.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.
const req: ReportSource = {
report: "Telerik.Reporting.Examples.CSharp.Invoice, CSharp.ReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
parameterValues: {
OrderNumber: "SO51081",
ForYear: 2003,
ForMonth: 7,
},
};
const reportingClient = new ReportingClient({ serverUrl: "https://....." });
reportingClient.register()
.then(() => reportingClient.createInstance(req))
.then((instance) => {
instance.createDocument({ format: documentFormat } as any).then((document) => {
document.download().then((file) => {
utils.ios.openFile(file.path);
viewModel.set("isBusyIn", false);
document.destroy()
.then(() => instance.destroy())
.then(() => reportingClient.unregister);
});
});
});
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 -ios
sufix.
bitcoin:14fjysmpwLvSsAskvLASw6ek5XfhTzskHC