DataTables logo DataTables

DataTables server-side processing example - automatic row ID addition

Preamble

Often when using server-side processing you will find that it can be useful to have a specific ID on each row (the row ID from the database for example). By assigning the ID you want to apply to each row using the property DT_RowId of the data source object for each row, DataTables will automatically add it for you. Likewise there is a DT_RowClass option which will add your given class. This example shows both and is a trivial modification of the server-side script to add these two options, with no changes on the client-side.

Live example

Rendering engine Browser Platform(s) Engine version CSS grade
Loading data from server
Rendering engine Browser Platform(s) Engine version CSS grade

Initialisation code

$(document).ready(function() {
	$('#example').dataTable( {
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "scripts/id.php"
	} );
} );

Server response

The code below shows the latest JSON data that has been returned from the server in response to the Ajax request made by DataTables. This will update as further requests are made.


			
			
			

Other examples