DataTables Editor - deep object data source example

Like DataTables, Editor has the ability to work with virtually any JSON data source. In DataTables the mData option is used to specify the field from a row's object to read for data, while in Editor the dataProp option is used (to clarify the difference between dataProp and name, dataProp is what is used to read the value from the DataTables row's data, while name is the name of the field that is submitted to the server - typically they will be the same, but do not need to be, as in this example).

This example shows the platform, version and grade values all nested within an object called details. dataProp options such as "details.platform" are used to retrieve the data for the rows.

Although this is a relatively simple example, nested data such as that shown here, can be exceptionally useful when working with joined tables.

Browser Rendering engine Platform(s) Engine version CSS grade
Browser Rendering engine Platform(s) Engine version CSS grade

Initialisation code

The Javascript below is what is used on this page for the example shown.


				

Table HTML

The HTML shown below shows the TABLE that is used in this example.


				

Server-side PHP

The code below is that HTML that is used to drive the server-side section of this exampe.


				

Included media files:

The HTML shown below includes the Javascript and CSS files that are required for the Editor operation on this page. You can use this as a template for your own pages, but if you move the files you might need to update the paths.


				

Communication of Editor between the client and server:

Editor submits and retrieves information by Ajax requests. The two blocks below show the data that Editor submits and receives, to and from the server. This is updated live as you interact with Editor so you can see what is submitted.

Submitted data:

The following shows the data that has been submitted to the server when a request is made to add, edit or delete data from the table.

// No data yet submitted

Server response:

The following shows the data that has been returned by the server in response to the data submitted on the left and is then acted upon.

// No data yet received

Data for DataTables from server:

DataTables can request information to display from the server when the page first loads. The block below shows the response from the server.


				

Examples

Basic:
Advanced: