load()
loads data from an external file
load?(url: string | DataProxy, driver?: object | string): Promise<any>;
Parameters:
url: string | IDataProxy
- the URL of an external file or DataProxy with the URL configureddriver: object | string
- optional, DataDriver or type of data ("json", "csv", "xml"), "json" by default
Returns:
A promise of data loading.
Example
component.data.load("../common/data.xml", "xml");
Related sample: Data. Load
info
Please note that if you specify the id
fields in the loaded data collection, their values should be unique. You can also omit the id
fields in the data collection. In this case they will be generated automatically.
The component will make an AJAX call and expect the remote URL to provide valid JSON data.
Data loading is asynchronous, so you need to wrap any after-loading code into a promise:
component.data.load(url).then(function(){
//do something after load;
});
or
component.data.load(url);
component.data.loadData.then(function(){
//do something after load;
});
// loadData executes a callback function after an asynchronous
// data loading has completed