@extends('layouts.simple.master') @section('title', 'Data Sources') @section('css') @endsection @section('main_content')
The foundation for DataTables is progressive enhancement, so it is very adept at reading table information directly from the DOM. This example shows how easy it is to add searching, ordering and paging to your HTML table by simply running DataTables on it.
DataTables has the ability to read data from virtually any
JSON data source that can be obtained by Ajax. This can be done, in its most
simple form, by setting the ajax:option
option to the address of
the JSON data source.
Name | Position | Office | Extn. | Start date | Salary |
---|---|---|---|---|---|
Name | Position | Office | Extn. | Start date | Salary |
At times you will wish to be able to create a table from
dynamic information passed directly to DataTables, rather than having it read
from the document.
This is achieved using the data
option in the
initialisation object, passing in an array of data to be used (like all other
DataTables handled data, this can be arrays or objects using thecolumns.data
option).
A table
must be
available on the page for DataTables to use. This examples shows an empty table
element being initialising as a
DataTable with a set of data from a Javascript array. The columns in the table
are dynamically created
based on the columns.title
configuration
option.
There are many ways to get your data into DataTables, and if you are working with seriously large databases, you might want to consider using the server-side options that DataTables provides. With server-side processing enabled, all paging, searching, ordering actions that DataTables performs are handed off to a server where an SQL engine (or similar) can perform these actions on the large data set (after all, that's what the database engine is designed for!). As such, each draw of the table will result in a new Ajax request being made to get the required data.
Server-side processing is enabled by setting the serverSide:option
option to
true
and providing an Ajax data source through the ajax:option
option.
First name | Last name | Position | Office | Start date | Salary |
---|---|---|---|---|---|
First name | Last name | Position | Office | Start date | Salary |