Demo App
To get you started with the DataTables libraries and Editor on your own server (or development machine), we provide a demo application that includes all of the Editor examples on this site, including their server-side scripts and the SQL for the backing database.
The demo app can be downloaded and then installed on your server or run locally. This guide will walk you through that process.
Download
To download the DataTables Node.js demo app, if you haven't already, open the Editor download page and download the Node.js package.
When the download completes, unzip the Editor-Nodejs-3.0.0-beta.1, ready for editing, running or uploading.
You next need to install dependencies, such as Express and Knex, which can be done in your CLI with:
npm install
Examples SQL
The next step is to load your database with the tables and data required for the Editor demos. The DataTables Node.js libraries work with a number of different databases, each of which requires its own SQL. The following links contain the SQL needed for each of the supported databases:
Select the appropriate file for your database and then run the SQL contained within on your database access portal (SQL Server Management Studio, CLI, phpMyAdmin or pgAdmin3 for example). The demo SQL will create new tables and enter data into them. Note that they will overwrite any conflicting table names - installing the demo into a new database is recommended and also, as is good practice, ensure that you have backed up your database.
Database connection
Open the file db.js and modify the data there with the connection information needed for your database. The connection to the database is made through Knex.js, allowing the libraries to work with a number of different database types and engines. The Knex.js documentation does an excellent job of explaining its own connection options.
Run the app
To start the Node.js application and spin up a web-server that will serve the demo app, in the CLI run:
npm run start
Instructions will then be printed on the screen with the address that you should load in your browser to view and interact with the examples.