DataTables add row example

Preamble

DataTables adding rows in DataTables is done by assigning the DataTables jQuery object to a variable when initialising it, and then using it's API methods to add a new row. Deleting rows can be done in a similar manner.

Live example

Click to add a new row

Column 1 Column 2 Column 3 Column 4
1.1 1.2 1.3 1.4

Initialisation code

/* Global variable for the DataTables object */
var oTable;

/* Global var for counter */
var giCount = 2;

$(document).ready(function() {
	oTable = $('#example').dataTable();
} );

function fnClickAddRow() {
	oTable.fnAddData( [
		giCount+".1",
		giCount+".2",
		giCount+".3",
		giCount+".4" ] );
	
	giCount++;
}

Other examples

Basic initialisation

Advanced initialisation

API

Please refer to the DataTables documentation for full information about it's API properties and methods.