3.18.1Generating downloads

You can trigger a download of data by using Framework.CreateDownload(). For example, MyTrader's built-in Account History widget uses this to do a download of the history in CSV format.

In a web browser, CreateDownload() simply triggers a download of the file. In the mobile/tablet app, it integrates with the device's notification centre, with options for sending the file to another app, saving it in the phone's storage etc.

CreateDownload() takes a single description object as a parameter which must contain the following properties:

Property

Description

fileName

Name of file to generate

mimeType

MIME type such as text/csv

data

File data (as a string)

For example:

Framework.CreateDownload({

fileName: "mydata.csv",

mimeType: "text/csv",

data: "Header1,Header2,Header3\r\nData1,Data2,Data3\r\netc"

});