Using a Custom Data Adapter
Our sample projects and report templates can help you learn the basics of working with our products.For a data source Reports.JS does not support natively, you can register a custom database that answers the engine's data commands yourself.
Register a custom database. Handle each command the engine issues:
How it works. The engine talks to your adapter through the same command protocol as built-in databases, so any source you can query in JavaScript becomes a report data source.
Register a custom database. Handle each command the engine issues:
Stimulsoft.Report.Dictionary.StiCustomDatabase.registerCustomDatabase({
serviceName: "MyDatabase",
process: function (command, callback) {
if (command.command == "TestConnection") callback({ success: true });
if (command.command == "RetrieveSchema") callback({ success: true, data: demoData, types: demoDataTypes });
if (command.command == "RetrieveData") callback({ success: true, data: demoData[command.queryString] });
}
});registerCustomDatabase({ serviceName, process })— plugs a bespoke data source into the dictionary.- The
processcallback answersTestConnection,RetrieveSchemaandRetrieveDatacommands with your own data.
How it works. The engine talks to your adapter through the same command protocol as built-in databases, so any source you can query in JavaScript becomes a report data source.