From 09a539b8117a25822fc5b1988d59ed4d53da9a4c Mon Sep 17 00:00:00 2001 From: Kiarash Ghiaseddin Date: Fri, 13 Feb 2015 14:25:32 +0100 Subject: [PATCH 1/7] New jquery.dataTables.d.ts for new API 1.10.x # complete file adding new Settings and API for dataTable # all methods and settings for 1.10.5 # basic testing --- jquery.dataTables/jquery.dataTables-tests.ts | 2327 +++++++----------- jquery.dataTables/jquery.dataTables.d.ts | 2061 ++++++++++++---- 2 files changed, 2479 insertions(+), 1909 deletions(-) diff --git a/jquery.dataTables/jquery.dataTables-tests.ts b/jquery.dataTables/jquery.dataTables-tests.ts index d3fe178c3..d94d68864 100755 --- a/jquery.dataTables/jquery.dataTables-tests.ts +++ b/jquery.dataTables/jquery.dataTables-tests.ts @@ -3,1443 +3,890 @@ // http://www.datatables.net/api -// $ - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Highlight every second row - oTable.$('tr:odd').css('backgroundColor', 'blue'); -} ); - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Filter to rows with 'Webkit' in them, add a background colour and then - // remove the filter, thus highlighting the 'Webkit' rows only. - oTable.fnFilter('Webkit'); - oTable.$('tr', {"filter": "applied"}).css('backgroundColor', 'blue'); - oTable.fnFilter(''); -} ); - -// _ - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Get the data from the first row in the table - var data = oTable._('tr:first'); - - // Do something useful with the data - alert( "First cell is: "+data[0] ); -} ); - - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Filter to 'Webkit' and get all data for - oTable.fnFilter('Webkit'); - var data = oTable._('tr', {"filter": "applied"}); - - // Do something with the data - alert( data.length+" rows matched the filter" ); -} ); - -// fnAddData - -var giCount = 2; - -$(document).ready(function() { - $('#example').dataTable(); -} ); - -function fnClickAddRow() { - $('#example').dataTable().fnAddData( [ - giCount+".1", - giCount+".2", - giCount+".3", - giCount+".4" ] - ); - - giCount++; -} - -// fnAdjustColumnSizing - -$(document).ready(function() { - var oTable = $('#example').dataTable( { - "sScrollY": "200px", - "bPaginate": false - } ); - - $(window).bind('resize', function () { - oTable.fnAdjustColumnSizing(); - } ); -} ); - -// fnClearTable - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...) - oTable.fnClearTable(); -} ); - -// fnClose - -$(document).ready(function() { - var oTable; - - // 'open' an information row when a row is clicked on - $('#example tbody tr').click( function () { - if ( oTable.fnIsOpen(this) ) { - oTable.fnClose( this ); - } else { - oTable.fnOpen( this, "Temporary row opened", "info_row" ); - } - } ); - - oTable = $('#example').dataTable(); -} ); - -// fnDeleteRow - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Immediately remove the first row - oTable.fnDeleteRow( 0 ); -} ); - -// fnDestroy - -$(document).ready(function() { - // This example is fairly pointless in reality, but shows how fnDestroy can be used - var oTable = $('#example').dataTable(); - oTable.fnDestroy(); -} ); - -// fnDraw - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Re-draw the table - you wouldn't want to do it here, but it's an example :-) - oTable.fnDraw(); -} ); - -// fnFilter - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Sometime later - filter... - oTable.fnFilter( 'test string' ); -} ); - -// fnGetData - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - oTable.$('tr').click( function () { - var data = oTable.fnGetData( this ); - // ... do something with the array / object of data for the row - } ); -} ); - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - oTable.$('td').click( function () { - var sData = oTable.fnGetData( this ); - alert( 'The cell clicked on had the value of '+sData ); - } ); -} ); - -// fnGetNodes - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Get the nodes from the table - var nNodes = oTable.fnGetNodes( ); -} ); - -// fnGetPosition - -$(document).ready(function() { - $('#example tbody td').click( function () { - // Get the position of the current data from the node - var aPos = oTable.fnGetPosition( this ); - - // Get the data array for this row - var aData = oTable.fnGetData( aPos[0] ); - - // Update the data array and return the value - aData[ aPos[1] ] = 'clicked'; - this.innerHTML = 'clicked'; - } ); - - // Init DataTables - var oTable = $('#example').dataTable(); -} ); - -// fnIsOpen - -$(document).ready(function() { - var oTable; - - // 'open' an information row when a row is clicked on - $('#example tbody tr').click( function () { - if ( oTable.fnIsOpen(this) ) { - oTable.fnClose( this ); - } else { - oTable.fnOpen( this, "Temporary row opened", "info_row" ); - } - } ); - - oTable = $('#example').dataTable(); -} ); - -// fnOpen - -$(document).ready(function() { - var oTable; - - // 'open' an information row when a row is clicked on - $('#example tbody tr').click( function () { - if ( oTable.fnIsOpen(this) ) { - oTable.fnClose( this ); - } else { - oTable.fnOpen( this, "Temporary row opened", "info_row" ); - } - } ); - - oTable = $('#example').dataTable(); -} ); - -// fnPageChange - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - oTable.fnPageChange( 'next' ); -} ); - -// fnSetColumnVis - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Hide the second column after initialisation - oTable.fnSetColumnVis( 1, false ); -} ); - -// fnSettings - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - var oSettings = oTable.fnSettings(); - - // Show an example parameter from the settings - alert("" + oSettings._iDisplayStart); -} ); - -// fnSort - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Sort immediately with columns 0 and 1 - oTable.fnSort( [ [0,'asc'], [1,'asc'] ] ); -} ); - -// fnSortListener - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - - // Sort on column 1, when 'sorter' is clicked on - oTable.fnSortListener( document.getElementById('sorter'), 1 ); -} ); - -// fnUpdate - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell - oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], 1 ); // Row -} ); - -// fnVersionCheck - -$(document).ready(function() { - var oTable = $('#example').dataTable(); - oTable.fnVersionCheck( '1.9.0'); -} ); - -// http://datatables.net/usage/features - -$(document).ready( function () { - $('#example').dataTable( { - "bAutoWidth": false - } ); -} ); - -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "sAjaxSource": "sources/arrays.txt", - "bDeferRender": true - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bFilter": false - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bInfo": false - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bJQueryUI": true - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bLengthChange": false - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bPaginate": false - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bProcessing": true - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bScrollInfinite": true, - "bScrollCollapse": true, - "sScrollY": "200px" - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bServerSide": true, - "sAjaxSource": "xhr.php" - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bSort": false - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bSortClasses": false - } ); -} ); - -$(document).ready( function () { - $('#example').dataTable( { - "bStateSave": true - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "sScrollX": "100%", - "bScrollCollapse": true - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "sScrollY": "200px", - "bPaginate": false - } ); -} ); - -// http://datatables.net/usage/options - -$(document).ready( function() { - $('#example').dataTable( { - "sScrollY": "200px", - "bPaginate": false - } ); - - // Some time later.... - $('#example').dataTable( { - "bFilter": false, - "bDestroy": true - } ); -} ); - -$(document).ready( function() { - initTable(); - tableActions(); -} ); - -function initTable () -{ - return $('#example').dataTable( { - "sScrollY": "200px", - "bPaginate": false, - "bRetrieve": true - } ); -} - -function tableActions () -{ - var oTable = initTable(); - // perform API operations with oTable -} - -$(document).ready( function() { - $('#example').dataTable( { - "bScrollAutoCss": false, - "sScrollY": "200px" - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "sScrollY": "200", - "bScrollCollapse": true - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bSortCellsTop": true - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "iCookieDuration": 60*60*24 // 1 day - } ); -} ); - -// 57 records available in the table, no filtering applied -$(document).ready( function() { - $('#example').dataTable( { - "bServerSide": true, - "sAjaxSource": "scripts/server_processing.php", - "iDeferLoading": 57 - } ); -} ); - - -// 57 records after filtering, 100 without filtering (an initial filter applied) -$(document).ready( function() { - $('#example').dataTable( { - "bServerSide": true, - "sAjaxSource": "scripts/server_processing.php", - "iDeferLoading": [ 57, 100 ], - "oSearch": { - "sSearch": "my_filter" - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "iDisplayLength": 50 - } ); -} ) - -$(document).ready( function() { - $('#example').dataTable( { - "iDisplayStart": 20 - } ); -} ) - -$(document).ready( function() { - $('#example').dataTable( { - "bScrollInfinite": true, - "bScrollCollapse": true, - "sScrollY": "200px", - "iScrollLoadGap": 50 - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "iTabIndex": 1 - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oSearch": {"sSearch": "Initial search"} - } ); -} ) - -// Get data from { "data": [...] } -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "sAjaxSource": "sources/data.txt", - "sAjaxDataProp": "data" - } ); -} ); - - -// Get data from { "data": { "inner": [...] } } -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "sAjaxSource": "sources/data.txt", - "sAjaxDataProp": "data.inner" - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "sAjaxSource": "http://www.sprymedia.co.uk/dataTables/json.php" - } ); -} ) - -$(document).ready( function() { - $('#example').dataTable( { - "sCookiePrefix": "my_datatable_" - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "sDom": '<"top"i>rt<"bottom"flp><"clear">' - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "sPaginationType": "full_numbers" - } ); -} ) - -$(document).ready( function() { - $('#example').dataTable( { - "sScrollX": "100%", - "sScrollXInner": "110%" - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bServerSide": true, - "sAjaxSource": "scripts/post.php", - "sServerMethod": "POST" - } ); -} ); - -// http://datatables.net/usage/callbacks - -$(document).ready( function () { - $('#example').dataTable( { - "fnCookieCallback": function (sName, oData, sExpires, sPath) { - // Customise oData or sName or whatever else here - return sName + "="+JSON.stringify(oData)+"; expires=" + sExpires +"; path=" + sPath; - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "fnCreatedRow": function( nRow, aData, iDataIndex ) { - // Bold the grade for all 'A' grade browsers - if ( aData[4] == "A" ) - { - $('td:eq(4)', nRow).html( 'A' ); - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "fnDrawCallback": function( oSettings ) { - alert( 'DataTables has redrawn the table' ); - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay ) { - ( (nFoot.getElementsByTagName('th')[0])).innerHTML = "Starting index is "+iStart; - } - } ); -} ) - -$(document).ready( function() { - $('#example').dataTable( { - "fnFormatNumber": function ( iIn ) { - if ( iIn < 1000 ) { - return iIn.toString(); - } else { - var - s=(iIn+""), - a=s.split(""), out="", - iLen=s.length; - - for ( var i=0 ; i nHead.getElementsByTagName('th')[0]).innerHTML = "Displaying "+(iEnd-iStart)+" records"; - } - } ); -} ) - -$('#example').dataTable( { - "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) { - return iStart +" to "+ iEnd; - } -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "fnInitComplete": function(oSettings, json) { - alert( 'DataTables has finished its initialisation.' ); - } - } ); -} ) - -$(document).ready( function() { - $('#example').dataTable( { - "fnPreDrawCallback": function( oSettings ) { - if ( $('#test').val() == 1 ) { - return false; - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { - // Bold the grade for all 'A' grade browsers - if ( aData[4] == "A" ) - { - $('td:eq(4)', nRow).html( 'A' ); - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bProcessing": true, - "bServerSide": true, - "sAjaxSource": "xhr.php", - "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { - oSettings.jqXHR = $.ajax( { - "dataType": 'json', - "type": "POST", - "url": sSource, - "data": aoData, - "success": fnCallback - } ); - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bProcessing": true, - "bServerSide": true, - "sAjaxSource": "scripts/server_processing.php", - "fnServerParams": function ( aoData ) { - aoData.push( { "name": "more_data", "value": "my_value" } ); - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bStateSave": true, - "fnStateLoad": function (oSettings) { - var o; - - // Send an Ajax request to the server to get the data. Note that - // this is a synchronous request. - $.ajax( { - "url": "/state_load", - "async": false, - "dataType": "json", - "success": function (json) { - o = json; - } - } ); - - return o; - } - } ); -} ); - -// Remove a saved filter, so filtering is never loaded -$(document).ready( function() { - $('#example').dataTable( { - "bStateSave": true, - "fnStateLoadParams": function (oSettings, oData) { - oData.oSearch.sSearch = ""; - } - } ); -} ); - - -// Disallow state loading by returning false -$(document).ready( function() { - $('#example').dataTable( { - "bStateSave": true, - "fnStateLoadParams": function (oSettings, oData) { - return false; - } - } ); -} ); - -// Show an alert with the filtering value that was saved -$(document).ready( function() { - $('#example').dataTable( { - "bStateSave": true, - "fnStateLoaded": function (oSettings, oData) { - alert( 'Saved filter was: '+oData.oSearch.sSearch ); - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bStateSave": true, - "fnStateSave": function (oSettings, oData) { - // Send an Ajax request to the server with the state object - $.ajax( { - "url": "/state_save", - "data": oData, - "dataType": "json", - "method": "POST", - "success": function () {} - } ); - } - } ); -} ); - -// Remove a saved filter, so filtering is never saved -$(document).ready( function() { - $('#example').dataTable( { - "bStateSave": true, - "fnStateSaveParams": function (oSettings, oData) { - oData.oSearch.sSearch = ""; - } - } ); -} ); - -// http://datatables.net/usage/columns - -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "aDataSort": [ 0, 1 ], "aTargets": [ 0 ] }, - { "aDataSort": [ 1, 0 ], "aTargets": [ 1 ] }, - { "aDataSort": [ 2, 3, 4 ], "aTargets": [ 2 ] } - ] - } ); -} ); - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "aDataSort": [ 0, 1 ] }, - { "aDataSort": [ 1, 0 ] }, - { "aDataSort": [ 2, 3, 4 ] }, - null, - null - ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "asSorting": [ "asc" ], "aTargets": [ 1 ] }, - { "asSorting": [ "desc", "asc", "asc" ], "aTargets": [ 2 ] }, - { "asSorting": [ "desc" ], "aTargets": [ 3 ] } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - null, - { "asSorting": [ "asc" ] }, - { "asSorting": [ "desc", "asc", "asc" ] }, - { "asSorting": [ "desc" ] }, - null - ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "bSearchable": false, "aTargets": [ 0 ] } - ] } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "bSearchable": false }, - null, - null, - null, - null - ] } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "bSortable": false, "aTargets": [ 0 ] } - ] } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "bSortable": false }, - null, - null, - null, - null - ] } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "bVisible": false, "aTargets": [ 0 ] } - ] } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "bVisible": false }, - null, - null, - null, - null - ] } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ { - "aTargets": [3], - "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) { - if ( sData == "1.7" ) { - $(nTd).css('color', 'blue') - } - } - } ] - }); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "iDataSort": 1, "aTargets": [ 0 ] } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "iDataSort": 1 }, - null, - null, - null, - null - ] - } ); -} ); - -// Read table data from objects -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "sAjaxSource": "sources/deep.txt", - "aoColumns": [ - { "mData": "engine" }, - { "mData": "browser" }, - { "mData": "platform.inner" }, - { "mData": "platform.details.0" }, - { "mData": "platform.details.1" } - ] - } ); -} ); - - -// Using mData as a function to provide different information for -// sorting, filtering and display. In this case, currency (price) -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "aoColumnDefs": [ { - "aTargets": [ 0 ], - "mData": function ( source, type, val ) { - if (type === 'set') { - source.price = val; - // Store the computed dislay and filter values for efficiency - source.price_display = val=="" ? "" : "$"+val; - source.price_filter = val=="" ? "" : "$"+val+" "+val; - return; - } - else if (type === 'display') { - return source.price_display; - } - else if (type === 'filter') { - return source.price_filter; - } - // 'sort', 'type' and undefined all just use the integer - return source.price; - } - } ] - } ); -} ); - -// Create a comma separated list from an array of objects -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "sAjaxSource": "sources/deep.txt", - "aoColumns": [ - { "mData": "engine" }, - { "mData": "browser" }, - { - "mData": "platform", - "mRender": "[, ].name" - } - ] - } ); -} ); - - -// Use as a function to create a link from the data source -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "aoColumnDefs": [ { - "aTargets": [ 0 ], - "mData": "download_link", - "mRender": function ( data, type, full ) { - return 'Download'; - } - } ] - } ); -} ); - -// Make the first column use TH cells -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "aoColumnDefs": [ { - "aTargets": [ 0 ], - "sCellType": "th" - } ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "sClass": "my_class", "aTargets": [ 0 ] } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "sClass": "my_class" }, - null, - null, - null, - null - ] - } ); -} ); - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - null, - null, - null, - { - "sContentPadding": "mmm" - } - ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { - "mData": null, - "sDefaultContent": "Edit", - "aTargets": [ -1 ] - } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - null, - null, - null, - { - "mData": null, - "sDefaultContent": "Edit" - } - ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "sName": "engine", "aTargets": [ 0 ] }, - { "sName": "browser", "aTargets": [ 1 ] }, - { "sName": "platform", "aTargets": [ 2 ] }, - { "sName": "version", "aTargets": [ 3 ] }, - { "sName": "grade", "aTargets": [ 4 ] } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "sName": "engine" }, - { "sName": "browser" }, - { "sName": "platform" }, - { "sName": "version" }, - { "sName": "grade" } - ] - } ); -} ); - -/* - -This test does not compile, because - for some hard to find reason - the compiler is missing the aTargets -property of the second element. - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "sSortDataType": "dom-text", "aTargets": [ 2, 3 ] }, - { "sType": "numeric", "aTargets": [ 3 ] }, - { "sSortDataType": "dom-select", "aTargets": [ 4 ] }, - { "sSortDataType": "dom-checkbox", "aTargets": [ 5 ] } - ] - } ); -} ); - -*/ - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - null, - null, - { "sSortDataType": "dom-text" }, - { "sSortDataType": "dom-text", "sType": "numeric" }, - { "sSortDataType": "dom-select" }, - { "sSortDataType": "dom-checkbox" } - ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "sTitle": "My column title", "aTargets": [ 0 ] } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "sTitle": "My column title" }, - null, - null, - null, - null - ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "sType": "html", "aTargets": [ 0 ] } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "sType": "html" }, - null, - null, - null, - null - ] - } ); -} ); - -// Using aoColumnDefs -$(document).ready( function() { - $('#example').dataTable( { - "aoColumnDefs": [ - { "sWidth": "20%", "aTargets": [ 0 ] } - ] - } ); -} ); - - -// Using aoColumns -$(document).ready( function() { - $('#example').dataTable( { - "aoColumns": [ - { "sWidth": "20%" }, - null, - null, - null, - null - ] - } ); -} ); - -// http://www.datatables.net/usage/i18n - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "oAria": { - "sSortAscending": " - click/return to sort ascending" - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "oAria": { - "sSortDescending": " - click/return to sort descending" - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "oPaginate": { - "sFirst": "First page" - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "oPaginate": { - "sLast": "Last page" - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "oPaginate": { - "sNext": "Next page" - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "oPaginate": { - "sPrevious": "Previous page" - } - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sEmptyTable": "No data available in table" - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sInfo": "Got a total of _TOTAL_ entries to show (_START_ to _END_)" - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sInfoEmpty": "No entries to show" - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sInfoFiltered": " - filtering from _MAX_ records" - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sInfoPostFix": "All records shown are derived from real information." - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sInfoThousands": "'" - } - } ); -} ); - -// Language change only -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sLengthMenu": "Display _MENU_ records" - } - } ); -} ); - - -// Language and options change -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sLengthMenu": 'Display records' - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sLoadingRecords": "Please wait - loading..." - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sProcessing": "DataTables is currently busy" - } - } ); -} ); - -// Input text box will be appended at the end automatically -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sSearch": "Filter records:" - } - } ); -} ); - - -// Specify where the filter should appear -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sSearch": "Apply filter _INPUT_ to table" - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sUrl": "http://www.sprymedia.co.uk/dataTables/lang.txt" - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "oLanguage": { - "sZeroRecords": "No records to display" - } - } ); -} ); - -// http://www.datatables.net/usage/server-side - -$(document).ready( function () { - $('#example').dataTable( { - "bServerSide": true, - "sAjaxSource": "xhr.php" - } ); -} ); - -// POST data to server -$(document).ready( function() { - $('#example').dataTable( { - "bProcessing": true, - "bServerSide": true, - "sAjaxSource": "xhr.php", - "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { - oSettings.jqXHR = $.ajax( { - "dataType": 'json', - "type": "POST", - "url": sSource, - "data": aoData, - "success": fnCallback - } ); - } - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "bProcessing": true, - "bServerSide": true, - "sAjaxSource": "scripts/server_processing.php", - "fnServerParams": function ( aoData ) { - aoData.push( { "name": "more_data", "value": "my_value" } ); - } - } ); -} ); - -// Get data from { "data": [...] } -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "sAjaxSource": "sources/data.txt", - "sAjaxDataProp": "data" - } ); -} ); - - -// Get data from { "data": { "inner": [...] } } -$(document).ready( function() { - var oTable = $('#example').dataTable( { - "sAjaxSource": "sources/data.txt", - "sAjaxDataProp": "data.inner" - } ); -} ); - -$(document).ready( function() { - $('#example').dataTable( { - "sAjaxSource": "http://www.sprymedia.co.uk/dataTables/json.php" - } ); -} ) - -$(document).ready( function() { - $('#example').dataTable( { - "bServerSide": true, - "sAjaxSource": "scripts/post.php", - "sServerMethod": "POST" - } ); -} ); +$(document).ready(function () { + //#region "Language" + + var lang: DataTables.LanguageSettings = { + "emptyTable": "No data available in table", + "info": "Showing _START_ to _END_ of _TOTAL_ entries", + "infoEmpty": "Showing 0 to 0 of 0 entries", + "infoFiltered": "(filtered from _MAX_ total entries)", + "infoPostFix": "", + "thousands": ",", + "lengthMenu": "Show _MENU_ entries", + "loadingRecords": "Loading...", + "processing": "Processing...", + "search": "Search:", + "zeroRecords": "No matching records found", + "paginate": { + "first": "First", + "last": "Last", + "next": "Next", + "previous": "Previous" + }, + "aria": { + "sortAscending": ": activate to sort column ascending", + "sortDescending": ": activate to sort column descending" + } + }; + + //#endregion "Language" + + //#region "Column" + + var colCreatedCellFunc: DataTables.IFunctionColumnCreatedCell = function (cell, cellData, rowData, rowIndex, colIndex) { + + } + + var colDataObject: DataTables.IObjectColumnData = { + _: "phone", + filter: "phone_filter", + display: "phone_display", + sort: "asc" + }; + + var colDataFunc: DataTables.IFunctionColumnData = function (row, type, set, meta) { + }; + + var colRenderObject: DataTables.IObjectColumnRender = { + _: "phone", + filter: "phone_filter", + display: "phone_display", + sort: "asc" + }; + + var colRenderFunc: DataTables.IFunctionColumnRender = function (data, type, row, meta) { + + }; + + var col: DataTables.ColumnSettings = + { + cellType: "th", + className: "css", + contentPadding: "mmmm", + createdCell: colCreatedCellFunc, + data: 1, + defaultContent: "edit", + name: "name", + orderable: true, + orderData: 10, + orderDataType: "dom-checkbox", + orderSequence: ['asc', 'desc'], + render: 1, + searchable: true, + title: "title", + visible: true, + width: "200px" + } + col = + { + data: "", + orderData: [10, 11, 20], + render: "", + } + col = + { + data: colDataObject, + render: colRenderObject, + } + col = + { + data: colDataFunc, + render: colRenderFunc, + } + + //#endregion "Column" + + //#region "ColumnDef" + + var colDef: DataTables.ColumnDefsSettings = + { + targets: 1, + cellType: "th", + className: "css", + contentPadding: "mmmm", + createdCell: colCreatedCellFunc, + data: 1, + defaultContent: "edit", + name: "name", + orderable: true, + orderData: 10, + orderDataType: "dom-checkbox", + orderSequence: ['asc', 'desc'], + render: 1, + searchable: true, + title: "title", + visible: true, + width: "200px" + }; + + colDef = + { + targets: "2", + cellType: "th", + }; + + colDef = + { + targets: ["2", 5], + cellType: "th", + }; + + //#endregion "ColumnDef" + + //#region "Callbacks" + + var createRowFunc: DataTables.IFunctionCreateRow = function (row, data, dataIndex) { }; + var drawCallbackFunc: DataTables.IFunctionDrawCallback = function (settings) { }; + var footerCallbackFunc: DataTables.IFunctionFooterCallback = function (tfoot, data, start, end, display) { }; + var formatNumberFunc: DataTables.IFunctionFormatNumber = function (toForm) { }; + var headerCallbackFunc: DataTables.IFunctionHeaderCallback = function (thead, data, start, end, display) { }; + var infoCallbackFunc: DataTables.IFunctionInfoCallback = function (settings, start, end, total, pre) { }; + var initCallbackFunc: DataTables.IFunctionInitComplete = function (settings, json) { }; + var preDrawFunc: DataTables.IFunctionPreDrawCallback = function (settings) { }; + var rowCallbackFunc: DataTables.IFunctionRowCallback = function (row, data) { }; + var stateLoadCallbackFunc: DataTables.IFunctionStateLoadCallback = function (settings) { }; + var stateLoadedCallbackFunc: DataTables.IFunctionStateLoaded = function (settings, data) { }; + var stateSaveCallbackFunc: DataTables.IFunctionStateSaveCallback = function (settings, data) { }; + var stateSaveParamsFunc: DataTables.IFunctionStateSaveParams = function (settings, data) { }; + + //#endregion "Callbacks + + //#region "Ajax" + + var ajaxFunc: DataTables.IFunctionAjax = function (data, callback, settings) { }; + + var ajaxDataFunc: DataTables.IFunctionAjaxData = function (data) { + return data; + }; + + ajaxDataFunc = function (data) { + return ""; + }; + + //#endregion "Ajax" + + //#region "Settings" + + var config: DataTables.Settings = + { + // columns + columns: [ + col, + null, + col, + null, + col, + col + ], + columnDefs: [ + null, + colDef, + colDef, + null, + ], + // Data + ajax: "url", + data: {}, + // Features + autoWidth: true, + deferRender: true, + info: true, + jQueryUI: false, + lengthChange: true, + ordering: true, + paging: true, + scrollX: true, + scrollY: "200px", + searching: true, + serverSide: true, + stateSave: true, + // Options + deferLoading: 10, + destroy: true, + displayStart: 1, + dom: "lrtip", + lengthMenu: [1, 2, 3, 4], + orderCellsTop: true, + orderClasses: true, + order: [[0, 'asc'], [1, 'asc']], + orderFixed: [[0, 'asc'], [1, 'asc']], + orderMulti: true, + pageLength: 10, + pagingType: "simple", + retrieve: true, + renderer: "bootstrap", + scrollCollapse: true, + search: true, + searchCols: [{ "search": "", "smart": true, "regex": false, "caseInsensitive": true }], + searchDelay: 10, + stateDuration: 10, + tabIndex: 10, + }; + + + config = + { + ajax: ajaxFunc, + deferLoading: [10, 100], + lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]], + order: [0, 'asc'], + orderFixed: [[0, 'asc'], [1, 'asc']], + renderer: { + header: "bootstrap", + pageButton: "jqueryui" + }, + search: { "search": "", "smart": true, "regex": false, "caseInsensitive": true }, + searchCols: [ + null, + { "search": "", "smart": true, "regex": false, "caseInsensitive": true }, + { "search": "" }, + { "search": "", "smart": true }, + null + ], + }; + + config = + { + ajax: { + data: {}, + dataSrc: "", + }, + }; + + config = + { + ajax: { + data: ajaxDataFunc, + dataSrc: function (data) { }, + }, + }; + + //#endregion "Settings" + + //#region "Init" + + var dt = $('#example').DataTable(); + dt = $('#example1').DataTable(config); + dt = $('#example1').DataTable(config); + dt.$('tr:odd').css('backgroundColor', 'blue'); + + //#endregion "Init" + + //#region "Methods-Ajax" + + var json = dt.ajax.json(); + + var params = dt.ajax.params(); + + var reload = dt.ajax.reload(); + reload = dt.ajax.reload(function () { }); + reload = dt.ajax.reload(function () { }, true); + var test = reload.$(""); + + var url = dt.ajax.url(); + dt.ajax.url("url"); + dt.ajax.url("url").load(); + + //#endregion "Methods-Ajax" + + //#region "Methods-Core" + + var clear = dt.clear(); + clear.$(""); + + var data = dt.data(); + data.$(""); + + var destroy = dt.destroy(); + destroy = dt.destroy(true); + destroy.$(""); + + var draw = dt.draw(); + draw = dt.draw(true); + draw.$(""); + + var off = dt.off("event"); + off = dt.off("event", function () { }); + off.$(""); + + var on = dt.on("event", function () { }); + on.$(""); + + var one = dt.one("event", function () { }); + one.$(""); + + var order_get = dt.order(); + var order_set = dt.order([0, "asc"]); + order_set = dt.order([0, "asc"], [1, "desc"]); // TODO: Fíx that + order_set = dt.order([[0, "asc"], [1, "desc"]]); + + var orderListerner = order_set.order.listener("node", 1, function () { }); + + var page_get = dt.page(); + var page_set = dt.page(1); + page_set = dt.page("next"); + + var page = dt.page.info(); + page = { + "page": 1, + "pages": 6, + "start": 10, + "end": 20, + "length": 10, + "recordsTotal": 57, + "recordsDisplay": 57 + }; + + var page_len_get = dt.page.len(); + var page_len_set = dt.page.len(10); + + var search_get = dt.search(); + var search_set = dt.search("searchStr"); + search_set = dt.search("searchStr", true); + search_set = dt.search("searchStr", true, false); + search_set = dt.search("searchStr", true, false, false); + + var settings = dt.settings(); + + var state = dt.state(); + state = { "time": 1423772610230, "start": 0, "length": 25, "order": [[0, "asc"]], "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true }, "columns": [{ "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }, { "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }, { "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }, { "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }, { "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }, { "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }, { "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }, { "visible": true, "search": { "search": "", "smart": true, "regex": false, "caseInsensitive": true } }] }; + state = dt.state.loaded(); + + var state_clear = dt.state.clear(); + state_clear.$(""); + + var state_save = dt.state.save(); + state_save.$(""); + + //#endregion "Methods-Core" + + var modifier: DataTables.IObjectSelectorModifier = { + order: "current", + search: "none", + page: "all", + }; + + //#region "Methods-Cell" + + var cells = dt.cells(); + cells = dt.cells(":contains('Not shipped')"); + cells = dt.cells(function () { }); + cells = dt.cells($("")); + cells = dt.cells({}); + cells = dt.cells(":contains('Not shipped')r", modifier); + cells = dt.cells("row-selector", "cells-selector", modifier); + + var cells_cache = cells.cache("search"); + // Create the select list and search operation + var select = $('') + .appendTo( + dt.column(colIdx).footer() + ) + .on('change', function () { + dt + .column(colIdx) + .search($(this).val()) + .draw(); + }); + + // Get the search data for the first column and add to the select list + dt + .column(colIdx) + .cache('search') + .sort() + .unique() + .each(function (d) { + select.append($('')); + }); + }); + + var columns_data = columns.data(); + //$('#listData').html( + // dt + // .columns(0) + // .data() + // .eq(0) // Reduce the 2D array into a 1D array of data + // .sort() // Sort data alphabetically + // .unique() // Reduce to unique values + // .join('
') + // ); + + //var idx = dt + // .columns('.check') + // .data() + // .eq(0) // Reduce the 2D array into a 1D array of data + // .indexOf('Yes'); + + var columns_dataSrc = columns.dataSrc(); + //alert('Data source: ' + dt.columns([0, 1]).dataSrc().join(' ')); + + var columns_footer = columns.footer(); + var columns_header = columns.header(); + var columns_indexes = columns.indexes(); + columns_indexes = columns.indexes("visibile"); + var columns_nodes = columns.nodes(); + dt + .columns('.ready') + .nodes() + //.flatten() // Reduce to a 1D array + //.to$() // Convert to a jQuery object + //.addClass('highlight'); + + var columns_search_get = columns.search(); + var columns_search_set = columns.search("string"); + columns_search_set = columns.search("string", true); + columns_search_set = columns.search("string", true, false); + columns_search_set = columns.search("string", true, false, true); + + var columns_visible_get = columns.visible(); + var columns_visible_set = columns.visible(false); + columns_visible_set = columns.visible(false, true); + // Hide a column + dt.column(1).visible(false); + dt.columns([0, 1, 2, 3]).visible(false, false); + dt.columns.adjust().draw(false); // adjust column sizing and redraw + + var columns_adjust = dt.columns.adjust(); + + var column = dt.column("selector"); + column = dt.column("selector", modifier); + + dt.column(0).visible(false); + + $('#example tbody').on('click', 'td', function () { + var visIdx = $(this).index(); + var dataIdx = dt.column.index('fromVisible', visIdx); + + alert('Column data index: ' + dataIdx + ', and visible index: ' + visIdx); + }); + + var column_cache = column.cache("order"); + // Create the select list and search operation + var select = $('') + // .appendTo( + // dt.column(colIdx).footer() + // ) + // .on('change', function () { + // dt + // .column(colIdx) + // .search($(this).val()) + // .draw(); + // }); + + // // Get the search data for the first column and add to the select list + // dt + // .column(colIdx) + // .cache('search') + // .sort() + // .unique() + // .each(function (d) { + // select.append($('')); + // }); + //}); + + var column_visible_get = column.visible(); + var column_visible_set = column.visible(false); + column_visible_set = column.visible(false, true); + alert('Column index 0 is ' + + (dt.column(0).visible() === true ? 'visible' : 'not visible') + ); + for (var i = 0; i < 4; i++) { + dt.column(i).visible(false, false); + } + dt.columns.adjust().draw(false); // adjust column sizing and redraw + + //#endregion "Methods-Column" + + //#region "Methods-Row" + + var row_1 = dt.row("selector"); + var row_2 = dt.row("selector").child.hide(); + var row_3 = dt.row("selector").child.isShown(); + var row_4 = dt.row("selector").child.remove(); + var row_5 = dt.row("selector").child.show(); + var row_6 = dt.row("selector").child(); + var row_7 = dt.row("selector").child(false); + var row_8 = dt.row("selector").child(false).hide(); + var row_9 = dt.row("selector").child("data"); + var row_10 = dt.row("selector").child("data").remove(); + var row_11 = dt.row("selector").child("data", "css").show(); + var row_12 = dt.row("selector").child.remove(); + var row_13 = dt.row("selector").child.show(); + var row_14 = dt.row.add({}); + var row_15 = dt.row("selector").invalidate(); + var row_16 = dt.row("selector").invalidate("auto"); + var row_17 = dt.row("selector").data(); + var row_18 = dt.row("selector").data({}); + var row_19 = dt.row("selector").index(); + var row_20 = dt.row("selector").node(); + var row_21 = dt.row("selector").remove(); + + var rows_1 = dt.rows(); + var rows_2 = dt.rows().remove(); + var rows_3 = dt.rows("selector"); + var rows_4 = dt.rows("selector").cache("type"); + var rows_5 = dt.rows("selector").data(); + var rows_6 = dt.rows("selector").data({}); + var rows_7 = dt.rows("selector").indexes(); + var rows_8 = dt.rows("selector").invalidate(); + var rows_9 = dt.rows("selector").invalidate("auto"); + var rows_10 = dt.rows("selector").indexes(); + var rows_11 = dt.rows("selector").remove(); + var rows_12 = dt.rows("selector").nodes(); + var rows_13 = dt.rows.add([{}, {}]); + + var table3 = $('#example').DataTable(); + table3.row.add({ + "name": "Tiger Nixon", + "position": "System Architect", + "salary": "$3,120", + "start_date": "2011/04/25", + "office": "Edinburgh", + "extn": "5421" + }).draw(); + + var table4 = $('#example').DataTable(); + table4.row.add([{ + "name": "Tiger Nixon", + "position": "System Architect", + "salary": "$3,120", + "start_date": "2011/04/25", + "office": "Edinburgh", + "extn": "5421" + }, { + "name": "Garrett Winters", + "position": "Director", + "salary": "$5,300", + "start_date": "2011/07/25", + "office": "Edinburgh", + "extn": "8422" + }]) + .draw(); + + var pupil: any; + var table5 = $('#example').DataTable(); + table5.rows.add([ + pupil, + pupil, + pupil, + ]) + .draw(); + //.nodes() + //.to$() + //.addClass('new'); + + $('#example tbody').on('click', 'td.details-control', function () { + var tr = $(this).parents('tr'); + var row = dt.row(tr); + + if (row.child.isShown()) { + // This row is already open - close it + row.child.hide(); + tr.removeClass('shown'); + } + else { + // Open this row (the format() function would return the data to be shown) + row.child("").show(); + tr.addClass('shown'); + } + }); + + dt.row(':eq(0)').child([ + 'First child row', + 'Second child row', + 'Third child row' + ]) + .show(); + + dt.rows().eq(0).each(function (rowIdx) { + dt + .row(rowIdx) + .child( + $( + '' + + '' + rowIdx + '.1' + + '' + rowIdx + '.2' + + '' + rowIdx + '.3' + + '' + rowIdx + '.4' + + '' + ) + ) + .show(); + }); + + $('#example tbody').on('click', 'td.details-control', function () { + var tr = $(this).parents('tr'); + var row = dt.row(tr); + + if (row.child.isShown()) { + // This row is already open - close it + row.child.hide(); + tr.removeClass('shown'); + } + else { + // Open this row (the format() function would return the data to be shown) + row.child("").show(); + tr.addClass('shown'); + } + }); + + $('#example tbody').on('click', 'td.details-control', function () { + var tr = $(this).parents('tr'); + var row = dt.row(tr); + + if (row.child.isShown()) { + // This row is already open - remove it + row.child.remove(); + tr.removeClass('shown'); + } + else { + // Open this row (the format() function would return the data to be shown) + row.child("").show(); + tr.addClass('shown'); + } + }); + + //#endregion "Methods-Row" + + //#region "Methods-Table" + + var tables = dt.tables(); + tables = dt.tables("selector"); + + var tables_body = tables.body(); + var tables_containers = tables.containers(); + var tables_footer = tables.footer(); + var tables_header = tables.header(); + var tables_nodes = tables.nodes(); + + var table = dt.table("selector"); + + var table_body = table.body(); + var table_container = table.container(); + var table_footer = table.footer(); + var table_header = table.header(); + var table_node = table.node(); + + //#endregion "Methods-Table" + + //#region "Methods-Util" + + //#endregion "Methods-Util" +}); diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index 9884b78e2..23087fbb7 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -1,479 +1,1602 @@ -// Type definitions for JQuery DataTables 1.9.4 +// Type definitions for JQuery DataTables 1.10.5 // Project: http://www.datatables.net -// Definitions by: Armin Sander +// Definitions by: Kiarash Ghiaseddin // Definitions: https://github.com/borisyankov/DefinitelyTyped // missing: // - Static methods that are defined in JQueryStatic.fn are not typed. // - Plugin and extension definitions are not typed. +// - Some return types are not fully wokring -interface JQuery -{ - dataTable(param? :DataTables.Options) : DataTables.DataTable; +interface JQuery { + DataTable(param?: DataTables.Settings): DataTables.DataTable; } -declare module DataTables -{ - export interface DataTable - { - /// Perform a jQuery selector action on the table's TR elements (from the tbody) and return the resulting jQuery object. - $(selector:string, opts?:RowParams): JQuery; - $(selector:Node[], opts?:RowParams): JQuery; - $(selector:JQuery, opts?:RowParams): JQuery; - - /// Almost identical to $ in operation, but in this case returns the data for the matched rows. - _(selector:string, opts?:RowParams): any[]; - _(selector:Node[], opts?:RowParams): any[]; - _(selector:JQuery, opts?:RowParams): any[]; - - /// Add a single new row or multiple rows of data to the table. - fnAddData(data:any, redraw?:boolean) : number[]; - - /// This function will make DataTables recalculate the column sizes. - fnAdjustColumnSizing(redraw? : boolean) : void; - - /// Quickly and simply clear a table - fnClearTable(redraw? : boolean) : void; - - /// The exact opposite of 'opening' a row, this function will close any rows which are currently 'open'. - fnClose(node: Node) : number; - - /// Remove a row for the table - fnDeleteRow(index: number, callback?: () => void, redraw?: boolean) : any[]; - fnDeleteRow(tr: Node, callback?: () => void, redraw?: boolean) : any[]; - - /// Restore the table to it's original state in the DOM by removing all of DataTables enhancements, - /// alterations to the DOM structure of the table and event listeners. - fnDestroy(remove?: boolean) : void; - - /// Redraw the table - fnDraw(complete? : boolean) : void; - - /// Filter the input based on data - fnFilter(input: string, column? : number, regex?: boolean, smart? : boolean, showGlobal?: boolean, caseInsensitive? : boolean) : void; - - /// Get the data for the whole table, an individual row or an individual cell based on the provided parameters. - fnGetData(row?: Node, col? : number) : any; - fnGetData(row?: number, col? : number) : any; - - /// Get an array of the TR nodes that are used in the table's body. - fnGetNodes(row? : number) : any; // Node[] | Node - - /// Get the array indexes of a particular cell from it's DOM element and column index including hidden columns - fnGetPosition(node: Node) : any; // number | number[] - - /// Check to see if a row is 'open' or not. - fnIsOpen(tr: Node) : boolean; - - /// This function will place a new row directly after a row which is currently on display on the page, - /// with the HTML contents that is passed into the function. - fnOpen(node: Node, html: string, clazz: string) : Node; - fnOpen(node: Node, html: Node, clazz: string) : Node; - fnOpen(node: Node, html: JQuery, clazz: string) : Node; - - /// Change the pagination - provides the internal logic for pagination in a simple API function. - fnPageChange(action: string, redraw?: boolean) : void; - fnPageChange(page: number, redraw?: boolean) : void; - - /// Show a particular column - fnSetColumnVis(column: number, show: boolean, redraw?: boolean) : void; - - /// Get the settings for a particular table for external manipulation - fnSettings() : Settings; - - /// Sort the table by a particular column - fnSort(col: number) : void; - fnSort(col: any[][]) : void; - - /// Attach a sort listener to an element for a given column - fnSortListener(node: Node, column: number, callback? : () => void): void; - - /// Update a table cell or row - this method will accept either a single value to update the cell with, - /// an array of values with one element for each column or an object in the same format as the original data source. - fnUpdate(data: any, row: Node, column?:number, redraw?: boolean, action? : boolean) : number; - fnUpdate(data: any, dataIndex: number, column?:number, redraw?: boolean, action? : boolean) : number; - - /// Provide a common method for plug-ins to check the version of DataTables being used, - /// in order to ensure compatibility. - fnVersionCheck(version: string) : boolean; - } - - export interface Static - { - /// Provide a common method for plug-ins to check the version of DataTables being used, - /// in order to ensure compatibility. - fnVersionCheck(version: string) : boolean; - - /// Check if a TABLE node is a DataTable table already or not. - fnIsDataTable(table: Node) : boolean; - - /// Get all DataTable tables that have been initialised. - fnTables(visible? : boolean) : Node[]; - } - - export interface RowParams - { - /// Select TR elements that meet the current filter criterion ("applied") or all TR elements (i.e. no filter). - filter?: string; - - /// Order of the TR elements in the processed array. - /// Can be either 'current', whereby the current sorting of the table is used, or - /// 'original' whereby the original order the data was read into the table is used. - order?: string; - - /// Limit the selection to the currently displayed page - /// ("current") or not ("all"). If 'current' is given, then order is assumed to be - /// 'current' and filter is 'applied', regardless of what they might be given as. - page?: string; - } - - export interface Options - { - aaData?: any[]; - aaSorting?: any[]; - aaSortingFixed?: any[]; - ajax?: any; - aLengthMenu?: any[]; - aoColumns?: ColumnOptions[]; - aoColumnDefs?: ColumnDef[]; - aoSearchCols?: any[]; - asStripClasses?: string[]; - bAutoWidth?: boolean; - bDeferRender?: boolean; - bDestroy?: boolean; - bFilter?: boolean; - bInfo?: boolean; - bJQueryUI?: boolean; - bLengthChange?: boolean; - bPaginate?: boolean; - bProcessing?: boolean; - bRetrieve?: boolean; - bScrollAutoCss?: boolean; - bScrollCollapse?: boolean; - bScrollInfinite?: boolean; - bServerSide?: boolean; - bSort?: boolean; - bSortCellsTop?: boolean; - bSortClasses?: boolean; - bStateSave?: boolean; - fnCookieCallback?: CookieCallback; - fnCreatedRow?: RowCreatedCallback; - fnDrawCallback?: DrawCallback; - fnFooterCallback?: FooterCallback; - fnFormatNumber?: FormatNumber; - fnHeaderCallback?: HeaderCallback; - fnInfoCallback?: InfoCallback; - fnInitComplete?: InitComplete; - fnPreDrawCallback?: PreDrawCallback; - fnRowCallback?: RowCallback; - - fnStateLoadCallback?: StateLoadCallback; - fnStateLoadParams?: StateLoadParams; - fnStateLoaded?: StateLoaded; - fnStateSaveCallback?: StateSaveCallback; - fnStateSaveParams?: StateSaveParams; - iCookieDuration?: number; - iDeferLoading?: any; - iDisplayLength?: number; - iDisplayStart?: number; - iScrollLoadGap?: number; - iTabIndex?: number; - oLanguage?: LanguageOptions; - oSearch?: any; - sAjaxDataProp?: string; - sAjaxSource?: string; - sCookiePrefix?: string; - sDom?: string; - sPaginationType?: string; - sScrollX?: string; - sScrollXInner?: string; - sScrollY?: string; - sServerMethod? : string; - } - - export interface LanguageOptions - { - oAria? : AriaOptions; - oPaginate? : PaginateOptions; - sEmptyTable?: string; - sInfo?: string; - sInfoEmpty?: string; - sInfoFiltered?: string; - sInfoPostFix?: string; - sInfoThousands?: string; - sLengthMenu?: string; - sLoadingRecords?: string; - sProcessing?: string; - sSearch?: string; - sUrl?: string; - sZeroRecords?: string; - } - - export interface AriaOptions - { - sSortAscending?: string; - sSortDescending?: string; - } - - export interface PaginateOptions - { - sFirst?: string; - sLast?: string; - sNext?: string; - sPrevious?: string; - } - - export interface ColumnOptions - { - aDataSort?: number[]; - asSorting?: string[]; - bSearchable? : boolean; - bSortable? : boolean; - bVisible? : boolean; - _bAutoType? : boolean; - fnCreatedCell?: CreatedCell; - iDataSort?: number; - mData?: any; - mRender?: any; - sCellType?: string; - sClass?: string; - sContentPadding?: string; - sDefaultContent?: string; - sName?: string; - sSortDataType?: string; - sSortingClass?: string; - sTitle?: string; - sType?: string; - sWidth?: string; - } - - export interface ColumnDef extends ColumnOptions - { - aTargets: any[]; - } - - export interface Settings - { - oFeatures : Features; - oScroll: ScrollingSettings; - oLanguage : { fnInfoCallback : InfoCallback; }; - oBrowser : { bScrollOversize : boolean; }; - aanFeatures: Node[][]; - aoData: Row[]; - aiDisplay: number[]; - aiDisplayMaster: number[]; - aoColumns: Column[]; - aoHeader: any[]; - aoFooter: any[]; - asDataSearch: string[]; - oPreviousSearch: any; - aoPreSearchCols: any[]; - aaSorting: any[][]; - aaSortingFixed: any[][]; - asStripeClasses: string[]; - asDestroyStripes: string[]; - sDestroyWidth: number; - aoRowCallback: RowCallback[]; - aoHeaderCallback: HeaderCallback[]; - aoFooterCallback: FooterCallback[]; - aoDrawCallback: DrawCallback[]; - aoRowCreatedCallback: RowCreatedCallback[]; - aoPreDrawCallback: PreDrawCallback[]; - aoInitComplete: InitComplete[]; - aoStateSaveParams: StateSaveParams[]; - aoStateLoadParams: StateLoadParams[]; - aoStateLoaded: StateLoaded[]; - sTableId: string; - nTable: Node; - nTHead: Node; - nTFoot: Node; - nTBody: Node; - nTableWrapper: Node; - bDeferLoading: boolean; - bInitialized: boolean; - aoOpenRows: any[]; - sDom: string; - sPaginationType: string; - iCookieDuration: number; - sCookiePrefix: string; - fnCookieCallback: CookieCallback; - aoStateSave: StateSaveCallback[]; - aoStateLoad: StateLoadCallback[]; - oLoadedState: any; - sAjaxSource: string; - sAjaxDataProp: string; - bAjaxDataGet: boolean; - jqXHR: any; - fnServerData: any; - aoServerParams: any[]; - sServerMethod: string; - fnFormatNumber: FormatNumber; - aLengthMenu: any[]; - iDraw: number; - bDrawing: boolean; - iDrawError: number; - _iDisplayLength: number; - _iDisplayStart: number; - _iDisplayEnd: number; - _iRecordsTotal: number; - _iRecordsDisplay: number; - bJUI: boolean; - oClasses: any; - bFiltered: boolean; - bSorted: boolean; - bSortCellsTop: boolean; - oInit: any; - aoDestroyCallback: any[]; - fnRecordsTotal: () => number; - fnRecordsDisplay: () => number; - fnDisplayEnd: () => number; - oInstance : any; - sInstance: string; - iTabIndex: number; - nScrollHead: Node; - nScrollFoot: Node; - } - - export interface Features - { - bAutoWidth: boolean; - bDeferRender: boolean; - bFilter: boolean; - bInfo: boolean; - bLengthChange: boolean; - bPaginate: boolean; - bProcessing: boolean; - bServerSide: boolean; - bSort: boolean; - bSortClasses: boolean; - bStateSave: boolean; - } - - export interface ScrollingSettings - { - bAutoCss : boolean; - bCollapse: boolean; - bInfinite: boolean; - iBarWidth: number; - iLoadGap: number; - sX: string; - sY: string; - } - - export interface Row - { - nTr: Node; - _aData: any; - _aSortData: any[]; - _anHidden: Node[]; - _sRowStripe: string; - } - - export interface Column - { - aDataSort: any; - asSorting: string[]; - bSearchable : boolean; - bSortable : boolean; - bVisible : boolean; - _bAutoType : boolean; - fnCreatedCell: CreatedCell; - fnGetData: (data: any, specific: string) => any; - fnSetData: (data: any, value: any) => void; - mData: any; - mRender: any; - nTh: Node; - nIf: Node; - sClass: string; - sContentPadding: string; - sDefaultContent: string; - sName: string; - sSortDataType: string; - sSortingClass: string; - sSortingClassJUI: string; - sTitle: string; - sType: string; - sWidth: string; - sWidthOrig: string; - } - - export interface CookieCallback - { - (name: string, data: any, expires: string, path: string, cookie: string) : void; - } - - export interface RowCreatedCallback - { - (row: Node, data: any[], dataIndex: number) : void; - } - - export interface DrawCallback - { - (settings: Settings) : void; - } - - export interface FooterCallback - { - (foot: Element, data: any[], start:number, end:number, display: number[]) : void; - } - - export interface FormatNumber - { - (toFormat: number) : string; - } - - export interface HeaderCallback - { - (head: Element, data: any[], start:number, end:number, display: number[]) : void; - } - - export interface InfoCallback - { - (settings: Settings, start: number, end: number, max:number, total: number, pre: string) : string; - } - - export interface InitComplete - { - (settings: Settings, json: any) : void; - } - - export interface PreDrawCallback - { - (settings: Settings) : boolean; - } - - export interface RowCallback - { - (row : Settings, data: any[], displayIndex: number, displayIndexFull: number) : void; - } - - export interface StateLoadCallback - { - (settings: Settings) : any; - } - - export interface StateLoadParams - { - (settings: Settings, data: any) : void; - } - - export interface StateLoaded - { - (settings: Settings, data: any) : void; - } - - export interface StateSaveCallback - { - (settings: any, data:any) : void; - } - - export interface StateSaveParams - { - (settings: any, data:any) : void; - } - - export interface CreatedCell - { - (nTd: Node, cellData: any, rowData: any, row: number, col: number) : void; - } +interface JQueryStatic { + //TODO: Wrong, as jquery.d.ts has no interface for fn + dataTable: DataTables.StaticFunctions; } + +declare module DataTables { + export interface DataTable extends DataTableCore { + /** + * Get the data for the whole table. + */ + data(): DataTable; + + /** + * Order Methods / Object + */ + order: OrderMethods; + + //#region "Cell/Cells" + + /** + * Select the cell found by a cell selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cell(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellMethods; + + /** + * Select the cell found by a cell selector + * + * @param rowSelector Row selector. + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cell(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellMethods; + + /** + * Select all cells + * + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cells(modifier?: IObjectSelectorModifier): CellsMethods; + + /** + * Select cells found by a cell selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cells(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellsMethods; + + /** + * Select cells found by both row and column selectors + * + * @param rowSelector Row selector. + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cells(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellsMethods; + //#endregion "Cell/Cells" + + //#region "Column/Columns" + + /** + * Column Methods / Object + */ + column: ColumnMethodsModel; + + /** + * Columns Methods / Object + */ + columns: ColumnsMethodsModel; + + //#endregion "Column/Columns" + + //#region "Row/Rows" + + /** + * Row Methode / Object + */ + row: RowMethodsModel + + /** + * Rows Methods / Object + */ + rows: RowsMethodsModel + + //#endregion "Row/Rows" + + //#region "Table/Tables" + + /** + * Select a table based on a selector from the API's context + * + * @param tableSelector Table selector. + */ + table(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TableMethods; + + /** + * Select all tables + */ + tables(): TablesMethods; + + /** + * Select tables based on the given selector + * + * @param tableSelector Table selector. + */ + tables(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TablesMethods; + + //#endregion "Table/Tables" + } + + export interface DataTables extends DataTableCore { + [index: number]: DataTable; + } + + interface IObjectSelectorModifier { + /** + * The order modifier provides the ability to control which order the rows are processed in. + * Values: 'current', 'applied', 'index', 'original' + */ + order?: string; + + /** + * The search modifier provides the ability to govern which rows are used by the selector using the search options that are applied to the table. + * Values: 'none', 'applied', 'removed' + */ + search?: string; + + /** + * The page modifier allows you to control if the selector should consider all data in the table, regardless of paging, or if only the rows in the currently disabled page should be used. + * Values: 'all', 'current' + */ + page?: string; + } + + //#region "Namespaces" + + //#region "core-methods" + + interface DataTableCore extends UtilityMethods { + /** + * Get jquery object + */ + $(selector: string | Node | Node[]| JQuery, modifier?: IObjectSelectorModifier): JQuery; + + ///// Almost identical to $ in operation, but in this case returns the data for the matched rows. + //_(selector: string | Node | Node[] | JQuery, modifier?: IObjectSelectorModifier): JQuery; + + /** + * Ajax Methods + */ + ajax: AjaxMethodModel; + + /** + * Clear the table of all data. + */ + clear(): DataTable; + + /** + * Destroy the DataTables in the current context. + * + * @param remove Completely remove the table from the DOM (true) or leave it in the DOM in its original plain un-enhanced HTML state (default, false). + */ + destroy(remove?: boolean): DataTable; + + /** + * Destroy the DataTables in the current context. + * + * @param reset Reset (default) or hold the current paging position. A full re-sort and re-filter is performed when this method is called, which is why the pagination reset is the default action. + */ + draw(reset?: boolean): DataTable; + + /** + * Table events removal. + * + * @param event Event name to remove. + * @param callback Specific callback function to remove if you want to unbind a single event listener. + */ + off(event: string, callback?: Function): DataTable; + + /** + * Table events listener. + * + * @param event Event to listen for. + * @param callback Specific callback function to remove if you want to unbind a single event listener. + */ + on(event: string, callback: Function): DataTable; + + /** + * Listen for a table event once and then remove the listener. + * + * @param event Event to listen for. + * @param callback Specific callback function to remove if you want to unbind a single event listener. + */ + one(event: string, callback: Function): DataTable; + + /** + * Page Methods / Object + */ + page: PageMethods; + + /** + * Get current search + */ + search(): string; + + /** + * Search for data in the table. + * + * @param input Search string to apply to the table. + * @param regex Treat as a regular expression (true) or not (default, false). + * @param smart Perform smart search. + * @param caseInsen Do case-insensitive matching (default, true) or not (false). + */ + search(input: string, regex?: boolean, smart?: boolean, caseInsen?: boolean): DataTable; + + /** + * Obtain the table's settings object + */ + settings(): DataTable; + + /** + * Page Methods / Object + */ + state: StateMethods; + } + + //#region "ajax-methods" + + interface AjaxMethods extends DataTable { + /** + * Reload the table data from the Ajax data source. + * + * @param callback Function which is executed when the data as been reloaded and the table fully redrawn. + * @param resetPaging Reset (default action or true) or hold the current paging position (false). + */ + load(callback?: Function, resetPaging?: boolean): DataTable; + } + + interface AjaxMethodModel { + /** + * Get the latest JSON data obtained from the last Ajax request DataTables made + */ + json(): Object; + + /** + * Get the data submitted by DataTables to the server in the last Ajax request + */ + params(): Object; + + /** + * Reload the table data from the Ajax data source. + * + * @param callback Function which is executed when the data as been reloaded and the table fully redrawn. + * @param resetPaging Reset (default action or true) or hold the current paging position (false). + */ + reload(callback?: Function, resetPaging?: boolean): DataTable; + + /** + * Reload the table data from the Ajax data source + */ + url(): string; + + /** + * Reload the table data from the Ajax data source + * + * @param url URL to set to be the Ajax data source for the table. + */ + url(url: string): AjaxMethods; + } + + //#endregion "ajax-methods" + + //#region "order-methods" + + interface OrderMethods { + /** + * Get the ordering applied to the table. + */ + (): (string | number)[][]; + + /** + * Set the ordering applied to the table. + * + * @param order Order Model + */ + (order?: (string | number)[]): DataTable; + (order?: (string | number)[][]): DataTable; + (order: (string | number)[], ...args: any[]): DataTable; + + /** + * Add an ordering listener to an element, for a given column. + * + * @param node Selector + * @param column Column index + * @param callback Callback function + */ + listener(node: string | Node | JQuery, column: number, callback: Function): DataTable; + } + //#endregion "order-methods" + + //#region "page-methods" + + interface PageMethods { + /** + * Get the current page of the table. + */ + (): number; + + /** + * Set the current page of the table. + * + * @param page Index or 'first', 'next', 'previous', 'last' + */ + (page: number | string): DataTable; + + /** + * Get paging information about the table + */ + info(): PageMethodeModelInfoReturn; + + /** + * Get the table's page length. + */ + len(): number; + + /** + * Set the table's page length. + * + * @param length Page length to set. use -1 to show all records. + */ + len(length: number): DataTable; + } + + interface PageMethodeModelInfoReturn { + page: number; + pages: number; + start: number; + end: number; + length: number; + recordsTotal: number; + recordsDisplay: number; + } + + //#endregion "page-methods" + + //#region "state-methods" + + interface StateMethods { + /** + * Get the last saved state of the table + */ + (): StateReturnModel; + + /** + * Clear the saved state of the table. + */ + clear(): DataTable; + + /** + * Get the table state that was loaded during initialisation. + */ + loaded(): StateReturnModel; + + /** + * Trigger a state save. + */ + save(): DataTable; + } + + interface StateReturnModel { + time: number; + start: number; + length: number; + order: (string | number)[][]; + search: SearchSettings; + columns: Array; + } + + //#endregion "state-methods" + + //#endregion "core-methods" + + //#region "util-methods" + + interface UtilityMethods { + /** + * Concatenate two or more API instances together + * + * @param a API instance to concatenate to the initial instance. + * @param b Additional API instance(s) to concatenate to the initial instance. + */ + concat(a: Object, ...b: Object[]): DataTable; + + /** + * Iterate over the contents of the API result set. + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters + */ + each(fn: Function): DataTable; + + /** + * Reduce an Api instance to a single context and result set. + * + * @param idx Index to select + */ + eq(idx: number): DataTable; + + /** + * Iterate over the result set of an API instance and test each item, creating a new instance from those items which pass. + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters. + */ + filter(fn: Function): DataTable; + + /** + * Flatten a 2D array structured API instance to a 1D array structure. + */ + flatten(): DataTable; + + /** + * Find the first instance of a value in the API instance's result set. + * + * @param value Value to find in the instance's result set. + */ + indexOf(value: any): number; + + /** + * Join the elements in the result set into a string. + * + * @param separator The string that will be used to separate each element of the result set. + */ + join(separator: string): string; + + /** + * Find the last instance of a value in the API instance's result set. + * + * @param value Value to find in the instance's result set. + */ + lastIndexOf(value: any): number; + + /** + * Number of elements in an API instance's result set. + */ + length: number; + + /** + * Iterate over the result set of an API instance, creating a new API instance from the values returned by the callback. + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters. + */ + map(fn: Function): DataTable; + + /** + * Iterate over the result set of an API instance, creating a new API instance from the values retrieved from the original elements. + * + * @param property Object property name to use from the element in the original result set for the new result set. + */ + pluck(property: number | string): DataTable; + + /** + * Remove the last item from an API instance's result set. + */ + pop(): any; + + /** + * Add one or more items to the end of an API instance's result set. + * + * @param value_1 Item to add to the API instance's result set. + */ + push(value_1: any | any[], ...value_2: any[]): number; + + /** + * Apply a callback function against and accumulator and each element in the Api's result set (left-to-right). + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters. + * @param initialValue Value to use as the first argument of the first call to the fn callback. + */ + reduce(fn: Function, initialValue?: any): any; + + /** + * Apply a callback function against and accumulator and each element in the Api's result set (right-to-left). + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters. + * @param initialValue Value to use as the first argument of the first call to the fn callback. + */ + reduceRight(fn: Function, initialValue?: any): any; + + /** + * Reverse the result set of the API instance and return the original array. + */ + reverse(): DataTable; + + /** + * Remove the first item from an API instance's result set. + */ + shift(): any; + + /** + * Sort the elements of the API instance's result set. + * + * @param fn This is a standard Javascript sort comparison function. It accepts two parameters. + */ + sort(fn?: Function): DataTable; + + /** + * Modify the contents of an Api instance's result set, adding or removing items from it as required. + * + * @param index Index at which to start modifying the Api instance's result set. + * @param howMany Number of elements to remove from the result set. + * @param value_1 Item to add to the result set at the index specified by the first parameter. + */ + splice(index: number, howMany: number, value_1?: any | any[], ...value_2: any[]): any[]; + + /** + * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set. + */ + to$(): JQuery; + + /** + * Create a native Javascript array object from an API instance. + */ + toArray(): any[]; + + /** + * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set. + */ + toJQuery(): JQuery; + + /** + * Create a new API instance containing only the unique items from a the elements in an instance's result set. + */ + unique(): DataTable; + + /** + * Add one or more items to the start of an API instance's result set. + * + * @param value_1 Item to add to the API instance's result set. + */ + unshift(value_1: any | any[], ...value_2: any[]): number; + } + + //#endregion "util-methods" + + interface CommonSubMethods { + /** + * Get the DataTables cached data for the selected cell + * + * @param t Specify which cache the data should be read from. Can take one of two values: search or order + */ + cache(t: string): DataTable; + } + + //#region "cell-methods" + + interface CommonCellMethods extends CommonSubMethods { + /** + * Invalidate the data held in DataTables for the selected cells + * + * @param source Data source to read the new data from. + */ + invalidate(source?: string): DataTable; + + /** + * Get data for the selected cell + * + * @param f Data type to get. This can be one of: 'display', 'filter', 'sort', 'type' + */ + render(t: string): any; + } + + interface CellMethods extends DataTableCore, CommonCellMethods { + /** + * Get data for the selected cell + */ + data(): any; + + /** + * Get data for the selected cell + * + * @param data Value to assign to the data for the cell + */ + data(data: any): DataTable; + + /** + * Get index information about the selected cell + */ + index(): CellIndexReturn; + + /** + * Get the DOM element for the selected cell + */ + node(): Node; + } + + interface CellIndexReturn { + row: number; + column: number; + columnVisible: number; + } + + interface CellsMethods extends DataTableCore, CommonCellMethods { + /** + * Get data for the selected cells + */ + data(): DataTable; + + /** + * Get index information about the selected cells + */ + indexes(): DataTable; + + /** + * Get the DOM elements for the selected cells + */ + nodes(): DataTable; + } + //#endregion "cell-methods" + + //#region "column-methods" + + interface CommonColumnMethod extends CommonSubMethods { + /** + * Get the footer th / td cell for the selected column. + */ + footer(): any; + + /** + * Get the header th / td cell for a column. + */ + header(): Node; + + /** + * Order the table, in the direction specified, by the column selected by the column()DT selector. + * + * @param direction Direction of sort to apply to the selected column - desc (descending) or asc (ascending). + */ + order(direction: string): DataTable; + + /** + * Get the visibility of the selected column. + */ + visible(): boolean; + + /** + * Set the visibility of the selected column. + * + * @param show Specify if the column should be visible (true) or not (false). + * @param redrawCalculations Indicate if DataTables should recalculate the column layout (true - default) or not (false). Typically this would be left as the default value, but it can be useful to disable when using the method in a loop - so the calculations are performed on every call as they can hamper performance. + */ + visible(show: boolean, redrawCalculations?: boolean): DataTable; + } + + interface ColumnMethodsModel { + /** + * Select the column found by a column selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (columnSelector: any, modifier?: IObjectSelectorModifier): ColumnMethods; + + /** + * Convert from the input column index type to that required. + * + * @param t The type on conversion that should take place: 'fromVisible', 'toData', 'fromData', 'toVisible' + * @param index The index to be converted + */ + index(t: string, index: number): number; + } + + interface ColumnMethods extends DataTableCore, CommonColumnMethod { + /** + * Get the data for the cells in the selected column. + */ + data(): DataTable[]; + + /** + * Get the data source property for the selected column + */ + dataSrc(): number | string | Function; + + /** + * Get index information about the selected cell + * + * @param t Specify if you want to get the column data index (default) or the visible index (visible). + */ + index(t?: string): DataTable; + + /** + * Obtain the th / td nodes for the selected column + */ + nodes(): DataTable[]; + } + + interface ColumnsMethodsModel { + /** + * Select all columns + * + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (modifier?: IObjectSelectorModifier): ColumnsMethods; + + /** + * Select columns found by a cell selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (columnSelector: any, modifier?: IObjectSelectorModifier): ColumnsMethods; + + /** + * Recalculate the column widths for layout. + */ + adjust(): DataTable; + } + + interface ColumnsMethods extends DataTableCore, CommonColumnMethod { + /** + * Obtain the data for the columns from the selector + */ + data(): DataTable[][]; + + /** + * Get the data source property for the selected columns. + */ + dataSrc(): DataTable; + + /** + * Get the column indexes of the selected columns. + * + * @param t Specify if you want to get the column data index (default) or the visible index (visible). + */ + indexes(t?: string): DataTable; + + /** + * Obtain the th / td nodes for the selected columns + */ + nodes(): DataTable[][]; + } + //#endregion "column-methods" + + //#region "row-methods" + + interface CommonRowMethod extends CommonSubMethods { + /** + * Obtain the th / td nodes for the selected column + * + * @param source Data source to read the new data from. Values: 'auto', 'data', 'dom' + */ + invalidate(source?: string): DataTable; + } + + interface RowChildMethodModel { + /** + * Get the child row(s) that have been set for a parent row + */ + (): JQuery; + + /** + * Get the child row(s) that have been set for a parent row + * + * @param showRemove This parameter can be given as true or false + */ + (showRemove: boolean): RowChildMethods; + + /** + * Set the data to show in the child row(s). Note that calling this method will replace any child rows which are already attached to the parent row. + * + * @param data The data to be shown in the child row can be given in multiple different ways. + * @param className Class name that is added to the td cell node(s) of the child row(s). As of 1.10.1 it is also added to the tr row node of the child row(s). + */ + (data: (string | Node | JQuery) | (string | Node | JQuery)[], className?: string): RowChildMethods; + + /** + * Hide the child row(s) of a parent row + */ + hide(): DataTable; + + /** + * Check if the child rows of a parent row are visible + */ + isShown(): DataTable; + + /** + * Remove child row(s) from display and release any allocated memory + */ + remove(): DataTable; + + /** + * Show the child row(s) of a parent row + */ + show(): DataTable; + } + + interface RowChildMethods extends DataTableCore { + /** + * Hide the child row(s) of a parent row + */ + hide(): DataTable; + + /** + * Remove child row(s) from display and release any allocated memory + */ + remove(): DataTable; + + /** + * Make newly defined child rows visible + */ + show(): DataTable; + } + + interface RowMethodsModel { + /** + * Select a row found by a row selector + * + * @param rowSelector Row selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (rowSelector: any, modifier?: IObjectSelectorModifier): RowMethods; + + /** + * Add a new row to the table using the given data + * + * @param data Data to use for the new row. This may be an array, object or Javascript object instance, but must be in the same format as the other data in the table + */ + add(data: any[]| Object): DataTable; + } + + interface RowMethods extends DataTableCore, CommonRowMethod { + /** + * Order Methods / Object + */ + child: RowChildMethodModel; + + /** + * Get the data for the selected row + */ + data(): any[]| Object; + + /** + * Set the data for the selected row + * + * @param d Data to use for the row. + */ + data(d: any[]| Object): DataTable; + + /** + * Get the row index of the row column. + */ + index(): number; + + /** + * Obtain the tr node for the selected row + */ + node(): Node; + + /** + * Delete the selected row from the DataTable. + */ + remove(): Node; + } + + interface RowsMethodsModel { + /** + * Select all rows + * + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (modifier?: IObjectSelectorModifier): RowsMethods; + + /** + * Select rows found by a row selector + * + * @param cellSelector Row selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (rowSelector: any, modifier?: IObjectSelectorModifier): RowsMethods; + + /** + * Add new rows to the table using the data given + * + * @param data Array of data elements, with each one describing a new row to be added to the table + */ + add(data: any[]): DataTable; + } + + interface RowsMethods extends DataTableCore, CommonRowMethod { + /** + * Get the data for the rows from the selector + */ + data(): DataTable; + + /** + * Set the data for the selected row + * + * @param d Data to use for the row. + */ + data(d: any[]| Object): DataTable; + + /** + * Get the row indexes of the selected rows. + */ + indexes(): DataTable; + + /** + * Obtain the tr nodes for the selected rows + */ + nodes(): DataTable; + + /** + * Delete the selected rows from the DataTable. + */ + remove(): DataTable; + } + //#endregion "row-methods" + + //#region "table-methods" + + interface TableMethods extends DataTableCore { + /** + * Get the tfoot node for the table in the API's context + */ + footer(): Node; + + /** + * Get the thead node for the table in the API's context + */ + header(): Node; + + /** + * Get the tbody node for the table in the API's context + */ + body(): Node; + + /** + * Get the div container node for the table in the API's context + */ + container(): Node; + + /** + * Get the table node for the table in the API's context + */ + node(): Node; + } + + interface TablesMethods extends DataTableCore { + /** + * Get the tfoot nodes for the tables in the API's context + */ + footer(): DataTable; + + /** + * Get the thead nodes for the tables in the API's context + */ + header(): DataTable; + + /** + * Get the tbody nodes for the tables in the API's context + */ + body(): DataTable; + + /** + * Get the div container nodes for the tables in the API's context + */ + containers(): DataTable; + + /** + * Get the table nodes for the tables in the API's context + */ + nodes(): DataTable; + } + //#endregion "table-methods" + + //#endregion "Namespaces" + + //#region "Static-Methods" + + export interface StaticFunctions { + /** + * Check is a table node is a DataTable or not + * + * @param table Selector string for table + */ + isDataTable(table: string): boolean; + + /** + * Get all DataTables on the page + * + * @param visible Get only visible tables + */ + tables(visible?: boolean): DataTables.DataTable[]; + + /** + * Version number compatibility check function + * + * @param version Version string + */ + versionCheck(version: string): boolean; + + /** + * Utils + */ + util: StaticUtilFunctions; + + /** + * Check is a table node is a DataTable or not + * + * @param table Selector string for table + */ + Api(selector: string | Node | Node[]| JQuery): DataTables.DataTable; + } + + export interface StaticUtilFunctions { + /** + * Escape special characters in a regular expression string. Since: 1.10.4 + * + * @param str String to escape + */ + escapeRegex(str: string): string; + + /** + * Throttle the calls to a method to reduce call frequency. Since: 1.10.3 + * + * @param fn Function + * @param period ms + */ + throttle(fn: Function, period?: number): Function; + } + + //#endregion "Static-Methods" + + //#region "Settings" + + export interface Settings { + + //#region "Features" + + /** + * Feature control DataTables' smart column width handling. Since: 1.10 + */ + autoWidth?: boolean; + + /** + * Feature control deferred rendering for additional speed of initialisation. Since: 1.10 + */ + deferRender?: boolean; + + /** + * Feature control table information display field. Since: 1.10 + */ + info?: boolean; + + /** + * Use markup and classes for the table to be themed by jQuery UI ThemeRoller. Since: 1.10 + */ + jQueryUI?: boolean; + + /** + * Feature control the end user's ability to change the paging display length of the table. Since: 1.10 + */ + lengthChange?: boolean; + + /** + * Feature control ordering (sorting) abilities in DataTables. Since: 1.10 + */ + ordering?: boolean; + + /** + * Enable or disable table pagination. Since: 1.10 + */ + paging?: boolean; + + /** + * Feature control the processing indicator. Since: 1.10 + */ + processing?: boolean; + + /** + * Horizontal scrolling. Since: 1.10 + */ + scrollX?: boolean; + + /** + * Vertical scrolling. Since: 1.10 Exp: "200px" + */ + scrollY?: string; + + /** + * Feature control search (filtering) abilities Since: 1.10 + */ + searching?: boolean; + + /** + * Feature control DataTables' server-side processing mode. Since: 1.10 + */ + serverSide?: boolean; + + /** + * State saving - restore table state on page reload. Since: 1.10 + */ + stateSave?: boolean; + + //#endregion "Features" + + //#region "Data" + + /** + * Load data for the table's content from an Ajax source. Since: 1.10 + */ + ajax?: string | AjaxSettings | IFunctionAjax; + + /** + * Data to use as the display data for the table. Since: 1.10 + */ + data?: Object; + + //#endregion "Data" + + //#region "Options" + + /** + * Data to use as the display data for the table. Since: 1.10 + */ + columns?: ColumnSettings[]; + + /** + * Assign a column definition to one or more columns.. Since: 1.10 + */ + columnDefs?: ColumnDefsSettings[]; + + /** + * Delay the loading of server-side data until second draw + */ + deferLoading?: number | number[]; + + /** + * Destroy any existing table matching the selector and replace with the new options. Since: 1.10 + */ + destroy?: boolean; + + /** + * Initial paging start point. Since: 1.10 + */ + displayStart?: number; + + /** + * Define the table control elements to appear on the page and in what order. Since: 1.10 + */ + dom?: string; + + /** + * Change the options in the page length select list. Since: 1.10 + */ + lengthMenu?: (number | string)[]| (number | string)[][]; + + /** + * Control which cell the order event handler will be applied to in a column. Since: 1.10 + */ + orderCellsTop?: boolean; + + /** + * Highlight the columns being ordered in the table's body. Since: 1.10 + */ + orderClasses?: boolean; + + /** + * Initial order (sort) to apply to the table. Since: 1.10 + */ + order?: (string | number)[]| (string | number)[][]; + + /** + * Ordering to always be applied to the table. Since: 1.10 + */ + orderFixed?: (string | number)[]| (string | number)[][]| Object; + + /** + * Multiple column ordering ability control. Since: 1.10 + */ + orderMulti?: boolean; + + /** + * Change the initial page length (number of rows per page). Since: 1.10 + */ + pageLength?: number; + + /** + * Pagination button display options. Basic Types: simple, simple_numbers, full, full_numbers + */ + pagingType?: string; + + /** + * Retrieve an existing DataTables instance. Since: 1.10 + */ + retrieve?: boolean + + /** + * Display component renderer types. Since: 1.10 + */ + renderer?: string | RendererSettings; + + /** + * Allow the table to reduce in height when a limited number of rows are shown. Since: 1.10 + */ + scrollCollapse?: boolean; + + /** + * Set an initial filter in DataTables and / or filtering options. Since: 1.10 + */ + search?: SearchSettings; + + /** + * Define an initial search for individual columns. Since: 1.10 + */ + searchCols?: SearchSettings[]; + + /** + * Set a throttle frequency for searching. Since: 1.10 + */ + searchDelay?: number; + + /** + * Saved state validity duration. Since: 1.10 + */ + stateDuration?: number; + + /** + * Set the zebra stripe class names for the rows in the table. Since: 1.10 + */ + stripeClasses?: string[]; + + /** + * Tab index control for keyboard navigation. Since: 1.10 + */ + tabIndex?: number; + + //#endregion "Options" + + //#region "Callbacks" + + /** + * Callback for whenever a TR element is created for the table's body. Since: 1.10 + */ + createdRow?: IFunctionCreateRow; + + /** + * Function that is called every time DataTables performs a draw. Since: 1.10 + */ + drawCallback?: IFunctionDrawCallback; + + /** + * Footer display callback function. Since: 1.10 + */ + footerCallback?: IFunctionFooterCallback; + + /** + * Number formatting callback function. Since: 1.10 + */ + formatNumber?: IFunctionFormatNumber; + + /** + * Header display callback function. Since: 1.10 + */ + headerCallback?: IFunctionHeaderCallback; + + /** + * Table summary information display callback. Since: 1.10 + */ + infoCallback?: IFunctionInfoCallback; + + /** + * Initialisation complete callback. Since: 1.10 + */ + initComplete?: IFunctionInitComplete; + + /** + * Pre-draw callback. Since: 1.10 + */ + preDrawCallback?: IFunctionPreDrawCallback; + + /** + * Row draw callback.. Since: 1.10 + */ + rowCallback?: IFunctionRowCallback; + + /** + * Callback that defines where and how a saved state should be loaded. Since: 1.10 + */ + stateLoadCallback?: IFunctionStateLoadCallback; + + /** + * State loaded callback. Since: 1.10 + */ + stateLoaded?: IFunctionStateLoaded; + + /** + * State loaded - data manipulation callback. Since: 1.10 + */ + stateLoadParams?: IFunctionStateLoadParams; + + /** + * Callback that defines how the table state is stored and where. Since: 1.10 + */ + stateSaveCallback?: IFunctionStateSaveCallback; + + /** + * State save - data manipulation callback. Since: 1.10 + */ + stateSaveParams?: IFunctionStateSaveParams; + + //#endregion "Callbacks" + + //#region "Language" + + language?: LanguageSettings; + + //#endregion "Language" + } + + //#region "ajax-settings" + + interface AjaxSettings extends JQueryAjaxSettings { + /** + * Add or modify data submitted to the server upon an Ajax request. Since: 1.10 + */ + data?: Object | IFunctionAjaxData; + + /** + * Data property or manipulation method for table data. Since: 1.10 + */ + dataSrc?: string | Function; + } + + interface IFunctionAjax { + (data: Object, callback: Function, settings: Settings): void; + } + + interface IFunctionAjaxData { + (data: Object): string | Object; + } + + //#endregion "ajax-settings" + + //#region "colunm-settings" + + export interface ColumnSettings { + /** + * Cell type to be created for a column. th/td Since: 1.10 + */ + cellType?: string; + + /** + * Class to assign to each cell in the column. Since: 1.10 + */ + className?: string; + + /** + * Add padding to the text content used when calculating the optimal with for a table. Since: 1.10 + */ + contentPadding?: string; + + /** + * Cell created callback to allow DOM manipulation. Since: 1.10 + */ + createdCell?: IFunctionColumnCreatedCell; + + /** + * Class to assign to each cell in the column. Since: 1.10 + */ + data?: number | string | IObjectColumnData | IFunctionColumnData; + + /** + * Set default, static, content for a column. Since: 1.10 + */ + defaultContent?: string; + + /** + * Set a descriptive name for a column. Since: 1.10 + */ + name?: string; + + /** + * Enable or disable ordering on this column. Since: 1.10 + */ + orderable?: boolean; + + /** + * Define multiple column ordering as the default order for a column. Since: 1.10 + */ + orderData?: number | number[]; + + /** + * Live DOM sorting type assignment. Since: 1.10 + */ + orderDataType?: string; + + /** + * Order direction application sequence. Since: 1.10 + */ + orderSequence?: string[]; + + /** + * Render (process) the data for use in the table. Since: 1.10 + */ + render?: number | string | IObjectColumnRender | IFunctionColumnRender; + + /** + * Enable or disable filtering on the data in this column. Since: 1.10 + */ + searchable?: boolean; + + /** + * Set the column title. Since: 1.10 + */ + title?: string; + + /** + * Set the column type - used for filtering and sorting string processing. Since: 1.10 + */ + type?: string; + + /** + * Enable or disable the display of this column. Since: 1.10 + */ + visible?: boolean; + + /** + * Column width assignment. Since: 1.10 + */ + width?: string; + } + + interface ColumnDefsSettings extends ColumnSettings { + targets: string | number | (number | string)[] + } + + interface IFunctionColumnCreatedCell { + (cell: Node, cellData: any, rowData: any, row: number, col: number): void; + } + + interface IFunctionColumnData { + (row: any, t: string, s: any, meta: Object): void; + } + + interface IObjectColumnData { + _: string; + filter?: string; + display?: string; + type?: string; + sort?: string; + } + + interface IObjectColumnRender extends IObjectColumnData { + } + + interface IFunctionColumnRender { + (data: Node, t: Node, row: Node, meta: Object): void; + } + + //#endregion "colunm-settings" + + //#region "other-settings" + + export interface RendererSettings { + header?: string; + pageButton?: string; + } + + export interface SearchSettings { + /** + * Control case-sensitive filtering option. Since: 1.10 + */ + caseInsensitive?: boolean; + + /** + * Enable / disable escaping of regular expression characters in the search term. Since: 1.10 + */ + regex?: boolean; + + /** + * Enable / disable DataTables' smart filtering. Since: 1.10 + */ + smart?: boolean; + + /** + * Set an initial filtering condition on the table. Since: 1.10 + */ + search?: string; + } + + //#endregion "other-settings" + + //#region "callback-functions" + + interface IFunctionCreateRow { + (row: Node, data: any[]| Object, dataIndex: number): void; + } + + interface IFunctionDrawCallback { + (settings: Settings): void; + } + + interface IFunctionFooterCallback { + (tfoot: Node, data: any[], start: number, end: number, display: any[]): void; + } + + interface IFunctionFormatNumber { + (formatNumber: number): void; + } + + interface IFunctionHeaderCallback { + (thead: Node, data: any[], start: number, end: number, display: any[]): void; + } + + interface IFunctionInfoCallback { + (settings: Settings, start: number, end: number, mnax: number, total: number, pre: string): void; + } + + interface IFunctionInitComplete { + (settings: Settings, json: Object): void; + } + + interface IFunctionPreDrawCallback { + (settings: Settings): void; + } + + interface IFunctionRowCallback { + (row: Node, data: any[]| Object): void; + } + + interface IFunctionStateLoadCallback { + (settings: Settings): void; + } + + interface IFunctionStateLoaded { + (settings: Settings, data: Object): void; + } + + interface IFunctionStateLoadParams { + (settings: Settings, data: Object): void; + } + + interface IFunctionStateSaveCallback { + (settings: Settings, data: Object): void; + } + + interface IFunctionStateSaveParams { + (settings: Settings, data: Object): void; + } + + //#endregion "callback-functions" + + //#region "language-settings" + + interface LanguageSettings { + emptyTable: string; + info: string; + infoEmpty: string; + infoFiltered: string; + infoPostFix: string; + thousands: string; + lengthMenu: string; + loadingRecords: string; + processing: string; + search: string; + zeroRecords: string; + paginate: LanguagePaginateSettings; + aria: LanguageAriaSettings; + } + + interface LanguagePaginateSettings { + first: string; + last: string; + next: string; + previous: string; + } + + interface LanguageAriaSettings { + sortAscending: string; + sortDescending: string; + } + + //#endregion "language-settings" + + //#endregion "Settings" +} \ No newline at end of file From 845b8e3ccb6969f4b7fc5a82d71d3d7a5620fa84 Mon Sep 17 00:00:00 2001 From: Kiarash Ghiaseddin Date: Wed, 18 Feb 2015 01:53:48 +0100 Subject: [PATCH 2/7] Add (legacy) Settings for internal api use # Add (legacy) Settings for internal api use # Remove I from naming # Update tests --- jquery.dataTables/jquery.dataTables-tests.ts | 127 ++++--- jquery.dataTables/jquery.dataTables.d.ts | 366 +++++++++++++++---- 2 files changed, 356 insertions(+), 137 deletions(-) diff --git a/jquery.dataTables/jquery.dataTables-tests.ts b/jquery.dataTables/jquery.dataTables-tests.ts index d94d68864..256693ab0 100755 --- a/jquery.dataTables/jquery.dataTables-tests.ts +++ b/jquery.dataTables/jquery.dataTables-tests.ts @@ -1,8 +1,3 @@ -/// -/// - -// http://www.datatables.net/api - $(document).ready(function () { //#region "Language" @@ -34,28 +29,28 @@ $(document).ready(function () { //#region "Column" - var colCreatedCellFunc: DataTables.IFunctionColumnCreatedCell = function (cell, cellData, rowData, rowIndex, colIndex) { + var colCreatedCellFunc: DataTables.FunctionColumnCreatedCell = function (cell, cellData, rowData, rowIndex, colIndex) { } - var colDataObject: DataTables.IObjectColumnData = { + var colDataObject: DataTables.ObjectColumnData = { _: "phone", filter: "phone_filter", display: "phone_display", sort: "asc" }; - var colDataFunc: DataTables.IFunctionColumnData = function (row, type, set, meta) { + var colDataFunc: DataTables.FunctionColumnData = function (row, type, set, meta) { }; - var colRenderObject: DataTables.IObjectColumnRender = { + var colRenderObject: DataTables.ObjectColumnRender = { _: "phone", filter: "phone_filter", display: "phone_display", sort: "asc" }; - var colRenderFunc: DataTables.IFunctionColumnRender = function (data, type, row, meta) { + var colRenderFunc: DataTables.FunctionColumnRender = function (data, type, row, meta) { }; @@ -136,27 +131,27 @@ $(document).ready(function () { //#region "Callbacks" - var createRowFunc: DataTables.IFunctionCreateRow = function (row, data, dataIndex) { }; - var drawCallbackFunc: DataTables.IFunctionDrawCallback = function (settings) { }; - var footerCallbackFunc: DataTables.IFunctionFooterCallback = function (tfoot, data, start, end, display) { }; - var formatNumberFunc: DataTables.IFunctionFormatNumber = function (toForm) { }; - var headerCallbackFunc: DataTables.IFunctionHeaderCallback = function (thead, data, start, end, display) { }; - var infoCallbackFunc: DataTables.IFunctionInfoCallback = function (settings, start, end, total, pre) { }; - var initCallbackFunc: DataTables.IFunctionInitComplete = function (settings, json) { }; - var preDrawFunc: DataTables.IFunctionPreDrawCallback = function (settings) { }; - var rowCallbackFunc: DataTables.IFunctionRowCallback = function (row, data) { }; - var stateLoadCallbackFunc: DataTables.IFunctionStateLoadCallback = function (settings) { }; - var stateLoadedCallbackFunc: DataTables.IFunctionStateLoaded = function (settings, data) { }; - var stateSaveCallbackFunc: DataTables.IFunctionStateSaveCallback = function (settings, data) { }; - var stateSaveParamsFunc: DataTables.IFunctionStateSaveParams = function (settings, data) { }; + var createRowFunc: DataTables.FunctionCreateRow = function (row, data, dataIndex) { }; + var drawCallbackFunc: DataTables.FunctionDrawCallback = function (settings) { }; + var footerCallbackFunc: DataTables.FunctionFooterCallback = function (tfoot, data, start, end, display) { }; + var formatNumberFunc: DataTables.FunctionFormatNumber = function (toForm) { }; + var headerCallbackFunc: DataTables.FunctionHeaderCallback = function (thead, data, start, end, display) { }; + var infoCallbackFunc: DataTables.FunctionInfoCallback = function (settings, start, end, total, pre) { }; + var initCallbackFunc: DataTables.FunctionInitComplete = function (settings, json) { }; + var preDrawFunc: DataTables.FunctionPreDrawCallback = function (settings) { }; + var rowCallbackFunc: DataTables.FunctionRowCallback = function (row, data) { }; + var stateLoadCallbackFunc: DataTables.FunctionStateLoadCallback = function (settings) { }; + var stateLoadedCallbackFunc: DataTables.FunctionStateLoaded = function (settings, data) { }; + var stateSaveCallbackFunc: DataTables.FunctionStateSaveCallback = function (settings, data) { }; + var stateSaveParamsFunc: DataTables.FunctionStateSaveParams = function (settings, data) { }; //#endregion "Callbacks //#region "Ajax" - var ajaxFunc: DataTables.IFunctionAjax = function (data, callback, settings) { }; + var ajaxFunc: DataTables.FunctionAjax = function (data, callback, settings) { }; - var ajaxDataFunc: DataTables.IFunctionAjaxData = function (data) { + var ajaxDataFunc: DataTables.FunctionAjaxData = function (data) { return data; }; @@ -361,7 +356,7 @@ $(document).ready(function () { //#endregion "Methods-Core" - var modifier: DataTables.IObjectSelectorModifier = { + var modifier: DataTables.ObjectSelectorModifier = { order: "current", search: "none", page: "all", @@ -534,15 +529,15 @@ $(document).ready(function () { }); var columns_data = columns.data(); - //$('#listData').html( - // dt - // .columns(0) - // .data() - // .eq(0) // Reduce the 2D array into a 1D array of data - // .sort() // Sort data alphabetically - // .unique() // Reduce to unique values - // .join('
') - // ); + $('#listData').html( + dt + .columns(0) + .data() + .eq(0) // Reduce the 2D array into a 1D array of data + .sort() // Sort data alphabetically + .unique() // Reduce to unique values + .join('
') + ); //var idx = dt // .columns('.check') @@ -610,20 +605,20 @@ $(document).ready(function () { dt .column(0) .cache('search') - // .sort() - // .unique() - // .each(function (d) { - // select.append($('')); - //}); + .sort() + .unique() + .each(function (d) { + select.append($('')); + }); var column_data = column.data(); alert('Column 4 sum: ' + dt .column(4) .data() - //.reduce(function (a, b) { - //return a + b; - //}) + .reduce(function (a, b) { + return a + b; + }) ); var column_dataSrc = column.dataSrc(); @@ -633,7 +628,7 @@ $(document).ready(function () { }); var column_footer = column.footer(); - //var column_p = dt.column(0); + var column_p = dt.column(0); //$(column.footer()).html( // column_p // .data() @@ -677,29 +672,29 @@ $(document).ready(function () { .draw(); }); - //dt.columns('.select-filter').eq(0).each(function (colIdx) { - // // Create the select list and search operation - // var select = $('') + .appendTo( + dt.column(colIdx).footer() + ) + .on('change', function () { + dt + .column(colIdx) + .search($(this).val()) + .draw(); + }); - // // Get the search data for the first column and add to the select list - // dt - // .column(colIdx) - // .cache('search') - // .sort() - // .unique() - // .each(function (d) { - // select.append($('')); - // }); - //}); + // Get the search data for the first column and add to the select list + dt + .column(colIdx) + .cache('search') + .sort() + .unique() + .each(function (d) { + select.append($('')); + }); + }); var column_visible_get = column.visible(); var column_visible_set = column.visible(false); diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index 23087fbb7..7c01189f2 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -12,10 +12,10 @@ interface JQuery { DataTable(param?: DataTables.Settings): DataTables.DataTable; } -interface JQueryStatic { - //TODO: Wrong, as jquery.d.ts has no interface for fn - dataTable: DataTables.StaticFunctions; -} +//TODO: Wrong, as jquery.d.ts has no interface for fn +//interface JQueryStatic { +// dataTable: DataTables.StaticFunctions; +//} declare module DataTables { export interface DataTable extends DataTableCore { @@ -37,7 +37,7 @@ declare module DataTables { * @param cellSelector Cell selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - cell(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellMethods; + cell(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods; /** * Select the cell found by a cell selector @@ -46,14 +46,14 @@ declare module DataTables { * @param cellSelector Cell selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - cell(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellMethods; + cell(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods; /** * Select all cells * * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - cells(modifier?: IObjectSelectorModifier): CellsMethods; + cells(modifier?: ObjectSelectorModifier): CellsMethods; /** * Select cells found by a cell selector @@ -61,7 +61,7 @@ declare module DataTables { * @param cellSelector Cell selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - cells(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellsMethods; + cells(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods; /** * Select cells found by both row and column selectors @@ -70,7 +70,7 @@ declare module DataTables { * @param cellSelector Cell selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - cells(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: IObjectSelectorModifier): CellsMethods; + cells(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods; //#endregion "Cell/Cells" //#region "Column/Columns" @@ -129,7 +129,7 @@ declare module DataTables { [index: number]: DataTable; } - interface IObjectSelectorModifier { + interface ObjectSelectorModifier { /** * The order modifier provides the ability to control which order the rows are processed in. * Values: 'current', 'applied', 'index', 'original' @@ -157,10 +157,10 @@ declare module DataTables { /** * Get jquery object */ - $(selector: string | Node | Node[]| JQuery, modifier?: IObjectSelectorModifier): JQuery; + $(selector: string | Node | Node[]| JQuery, modifier?: ObjectSelectorModifier): JQuery; ///// Almost identical to $ in operation, but in this case returns the data for the matched rows. - //_(selector: string | Node | Node[] | JQuery, modifier?: IObjectSelectorModifier): JQuery; + //_(selector: string | Node | Node[] | JQuery, modifier?: ObjectSelectorModifier): JQuery; /** * Ajax Methods @@ -390,7 +390,12 @@ declare module DataTables { length: number; order: (string | number)[][]; search: SearchSettings; - columns: Array; + columns: StateReturnModelColumns[]; + } + + interface StateReturnModelColumns { + search: SearchSettings; + visible: boolean; } //#endregion "state-methods" @@ -674,7 +679,7 @@ declare module DataTables { * @param cellSelector Cell selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - (columnSelector: any, modifier?: IObjectSelectorModifier): ColumnMethods; + (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnMethods; /** * Convert from the input column index type to that required. @@ -689,7 +694,7 @@ declare module DataTables { /** * Get the data for the cells in the selected column. */ - data(): DataTable[]; + data(): DataTable; /** * Get the data source property for the selected column @@ -715,7 +720,7 @@ declare module DataTables { * * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - (modifier?: IObjectSelectorModifier): ColumnsMethods; + (modifier?: ObjectSelectorModifier): ColumnsMethods; /** * Select columns found by a cell selector @@ -723,7 +728,7 @@ declare module DataTables { * @param cellSelector Cell selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - (columnSelector: any, modifier?: IObjectSelectorModifier): ColumnsMethods; + (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnsMethods; /** * Recalculate the column widths for layout. @@ -735,7 +740,7 @@ declare module DataTables { /** * Obtain the data for the columns from the selector */ - data(): DataTable[][]; + data(): DataTable; /** * Get the data source property for the selected columns. @@ -833,7 +838,7 @@ declare module DataTables { * @param rowSelector Row selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - (rowSelector: any, modifier?: IObjectSelectorModifier): RowMethods; + (rowSelector: any, modifier?: ObjectSelectorModifier): RowMethods; /** * Add a new row to the table using the given data @@ -883,7 +888,7 @@ declare module DataTables { * * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - (modifier?: IObjectSelectorModifier): RowsMethods; + (modifier?: ObjectSelectorModifier): RowsMethods; /** * Select rows found by a row selector @@ -891,7 +896,7 @@ declare module DataTables { * @param cellSelector Row selector. * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. */ - (rowSelector: any, modifier?: IObjectSelectorModifier): RowsMethods; + (rowSelector: any, modifier?: ObjectSelectorModifier): RowsMethods; /** * Add new rows to the table using the data given @@ -1124,7 +1129,7 @@ declare module DataTables { /** * Load data for the table's content from an Ajax source. Since: 1.10 */ - ajax?: string | AjaxSettings | IFunctionAjax; + ajax?: string | AjaxSettings | FunctionAjax; /** * Data to use as the display data for the table. Since: 1.10 @@ -1257,72 +1262,72 @@ declare module DataTables { /** * Callback for whenever a TR element is created for the table's body. Since: 1.10 */ - createdRow?: IFunctionCreateRow; + createdRow?: FunctionCreateRow; /** * Function that is called every time DataTables performs a draw. Since: 1.10 */ - drawCallback?: IFunctionDrawCallback; + drawCallback?: FunctionDrawCallback; /** * Footer display callback function. Since: 1.10 */ - footerCallback?: IFunctionFooterCallback; + footerCallback?: FunctionFooterCallback; /** * Number formatting callback function. Since: 1.10 */ - formatNumber?: IFunctionFormatNumber; + formatNumber?: FunctionFormatNumber; /** * Header display callback function. Since: 1.10 */ - headerCallback?: IFunctionHeaderCallback; + headerCallback?: FunctionHeaderCallback; /** * Table summary information display callback. Since: 1.10 */ - infoCallback?: IFunctionInfoCallback; + infoCallback?: FunctionInfoCallback; /** * Initialisation complete callback. Since: 1.10 */ - initComplete?: IFunctionInitComplete; + initComplete?: FunctionInitComplete; /** * Pre-draw callback. Since: 1.10 */ - preDrawCallback?: IFunctionPreDrawCallback; + preDrawCallback?: FunctionPreDrawCallback; /** * Row draw callback.. Since: 1.10 */ - rowCallback?: IFunctionRowCallback; + rowCallback?: FunctionRowCallback; /** * Callback that defines where and how a saved state should be loaded. Since: 1.10 */ - stateLoadCallback?: IFunctionStateLoadCallback; + stateLoadCallback?: FunctionStateLoadCallback; /** * State loaded callback. Since: 1.10 */ - stateLoaded?: IFunctionStateLoaded; + stateLoaded?: FunctionStateLoaded; /** * State loaded - data manipulation callback. Since: 1.10 */ - stateLoadParams?: IFunctionStateLoadParams; + stateLoadParams?: FunctionStateLoadParams; /** * Callback that defines how the table state is stored and where. Since: 1.10 */ - stateSaveCallback?: IFunctionStateSaveCallback; + stateSaveCallback?: FunctionStateSaveCallback; /** * State save - data manipulation callback. Since: 1.10 */ - stateSaveParams?: IFunctionStateSaveParams; + stateSaveParams?: FunctionStateSaveParams; //#endregion "Callbacks" @@ -1335,11 +1340,47 @@ declare module DataTables { //#region "ajax-settings" + export interface AjaxDataRequest { + draw: number; + start: number; + length: number; + data: any; + order: AjaxDataRequestOrder[]; + columns: AjaxDataRequestColumn[]; + search: AjaxDataRequestSearch; + } + + export interface AjaxDataRequestSearch { + value: string; + regex: boolean; + } + + export interface AjaxDataRequestOrder { + column: number; + dir: string; + } + + export interface AjaxDataRequestColumn { + data: string | number; + name: string; + searchable: boolean; + orderable: boolean; + search: AjaxDataRequestSearch; + } + + export interface AjaxData { + draw: number; + recordsTotal: number; + recordsFiltered: number; + data: any; + error?: string; + } + interface AjaxSettings extends JQueryAjaxSettings { /** * Add or modify data submitted to the server upon an Ajax request. Since: 1.10 */ - data?: Object | IFunctionAjaxData; + data?: Object | FunctionAjaxData; /** * Data property or manipulation method for table data. Since: 1.10 @@ -1347,11 +1388,11 @@ declare module DataTables { dataSrc?: string | Function; } - interface IFunctionAjax { - (data: Object, callback: Function, settings: Settings): void; + interface FunctionAjax { + (data: Object, callback: Function, settings: SettingsLegacy): void; } - interface IFunctionAjaxData { + interface FunctionAjaxData { (data: Object): string | Object; } @@ -1378,12 +1419,12 @@ declare module DataTables { /** * Cell created callback to allow DOM manipulation. Since: 1.10 */ - createdCell?: IFunctionColumnCreatedCell; + createdCell?: FunctionColumnCreatedCell; /** * Class to assign to each cell in the column. Since: 1.10 */ - data?: number | string | IObjectColumnData | IFunctionColumnData; + data?: number | string | ObjectColumnData | FunctionColumnData; /** * Set default, static, content for a column. Since: 1.10 @@ -1418,7 +1459,7 @@ declare module DataTables { /** * Render (process) the data for use in the table. Since: 1.10 */ - render?: number | string | IObjectColumnRender | IFunctionColumnRender; + render?: number | string | ObjectColumnRender | FunctionColumnRender; /** * Enable or disable filtering on the data in this column. Since: 1.10 @@ -1450,15 +1491,15 @@ declare module DataTables { targets: string | number | (number | string)[] } - interface IFunctionColumnCreatedCell { + interface FunctionColumnCreatedCell { (cell: Node, cellData: any, rowData: any, row: number, col: number): void; } - interface IFunctionColumnData { + interface FunctionColumnData { (row: any, t: string, s: any, meta: Object): void; } - interface IObjectColumnData { + interface ObjectColumnData { _: string; filter?: string; display?: string; @@ -1466,10 +1507,10 @@ declare module DataTables { sort?: string; } - interface IObjectColumnRender extends IObjectColumnData { + interface ObjectColumnRender extends ObjectColumnData { } - interface IFunctionColumnRender { + interface FunctionColumnRender { (data: Node, t: Node, row: Node, meta: Object): void; } @@ -1508,60 +1549,60 @@ declare module DataTables { //#region "callback-functions" - interface IFunctionCreateRow { + interface FunctionCreateRow { (row: Node, data: any[]| Object, dataIndex: number): void; } - interface IFunctionDrawCallback { - (settings: Settings): void; + interface FunctionDrawCallback { + (settings: SettingsLegacy): void; } - interface IFunctionFooterCallback { + interface FunctionFooterCallback { (tfoot: Node, data: any[], start: number, end: number, display: any[]): void; } - interface IFunctionFormatNumber { + interface FunctionFormatNumber { (formatNumber: number): void; } - interface IFunctionHeaderCallback { + interface FunctionHeaderCallback { (thead: Node, data: any[], start: number, end: number, display: any[]): void; } - interface IFunctionInfoCallback { - (settings: Settings, start: number, end: number, mnax: number, total: number, pre: string): void; + interface FunctionInfoCallback { + (settings: SettingsLegacy, start: number, end: number, mnax: number, total: number, pre: string): void; } - interface IFunctionInitComplete { - (settings: Settings, json: Object): void; + interface FunctionInitComplete { + (settings: SettingsLegacy, json: Object): void; } - interface IFunctionPreDrawCallback { - (settings: Settings): void; + interface FunctionPreDrawCallback { + (settings: SettingsLegacy): void; } - interface IFunctionRowCallback { + interface FunctionRowCallback { (row: Node, data: any[]| Object): void; } - interface IFunctionStateLoadCallback { - (settings: Settings): void; + interface FunctionStateLoadCallback { + (settings: SettingsLegacy): void; } - interface IFunctionStateLoaded { - (settings: Settings, data: Object): void; + interface FunctionStateLoaded { + (settings: SettingsLegacy, data: Object): void; } - interface IFunctionStateLoadParams { - (settings: Settings, data: Object): void; + interface FunctionStateLoadParams { + (settings: SettingsLegacy, data: Object): void; } - interface IFunctionStateSaveCallback { - (settings: Settings, data: Object): void; + interface FunctionStateSaveCallback { + (settings: SettingsLegacy, data: Object): void; } - interface IFunctionStateSaveParams { - (settings: Settings, data: Object): void; + interface FunctionStateSaveParams { + (settings: SettingsLegacy, data: Object): void; } //#endregion "callback-functions" @@ -1599,4 +1640,187 @@ declare module DataTables { //#endregion "language-settings" //#endregion "Settings" + + //#region "SettingsLegacy" + + interface ArrayStringNode { + [index: string]: Node; + } + + export interface SettingsLegacy { + oApi: any; + oFeatures: FeaturesLegacy; + oScroll: ScrollingLegacy; + oLanguage: LanguageLegacy; // | { fnInfoCallback: FunctionInfoCallback; }; + oBrowser: { bScrollOversize: boolean; }; + aanFeatures: ArrayStringNode[][]; + aoData: RowLegacy[]; + aiDisplay: number[]; + //bServerSide: boolean; + aiDisplayMaster: number[]; + aoColumns: ColumnLegacy[]; + aoHeader: any[]; + aoFooter: any[]; + asDataSearch: string[]; + oPreviousSearch: any; + aoPreSearchCols: any[]; + aaSorting: any[][]; + aaSortingFixed: any[][]; + asStripeClasses: string[]; + asDestroyStripes: string[]; + sDestroyWidth: number; + aoRowCallback: FunctionRowCallback[]; + aoHeaderCallback: FunctionHeaderCallback[]; + aoFooterCallback: FunctionFooterCallback[]; + aoDrawCallback: FunctionDrawCallback[]; + aoRowCreatedCallback: FunctionCreateRow[]; + aoPreDrawCallback: FunctionPreDrawCallback[]; + aoInitComplete: FunctionInitComplete[]; + aoStateSaveParams: FunctionStateSaveParams[]; + aoStateLoadParams: FunctionStateLoadParams[]; + aoStateLoaded: FunctionStateLoaded[]; + sTableId: string; + nTable: Node; + nTHead: Node; + nTFoot: Node; + nTBody: Node; + nTableWrapper: Node; + bDeferLoading: boolean; + bInitialized: boolean; + aoOpenRows: any[]; + sDom: string; + sPaginationType: string; + iCookieDuration: number; + sCookiePrefix: string; + fnCookieCallback: CookieCallbackLegacy; + aoStateSave: FunctionStateSaveCallback[]; + aoStateLoad: FunctionStateLoadCallback[]; + oLoadedState: any; + sAjaxSource: string; + sAjaxDataProp: string; + bAjaxDataGet: boolean; + jqXHR: any; + fnServerData: any; + aoServerParams: any[]; + sServerMethod: string; + fnFormatNumber: FunctionFormatNumber; + aLengthMenu: any[]; + iDraw: number; + bDrawing: boolean; + iDrawError: number; + _iDisplayLength: number; + _iDisplayStart: number; + _iDisplayEnd: number; + _iRecordsTotal: number; + _iRecordsDisplay: number; + bJUI: boolean; + oClasses: any; + bFiltered: boolean; + bSorted: boolean; + bSortCellsTop: boolean; + oInit: any; + aoDestroyCallback: any[]; + fnRecordsTotal: () => number; + fnRecordsDisplay: () => number; + fnDisplayEnd: () => number; + oInstance: any; + sInstance: string; + iTabIndex: number; + nScrollHead: Node; + nScrollFoot: Node; + } + + export interface FeaturesLegacy { + bAutoWidth: boolean; + bDeferRender: boolean; + bFilter: boolean; + bInfo: boolean; + bLengthChange: boolean; + bPaginate: boolean; + bProcessing: boolean; + bServerSide: boolean; + bSort: boolean; + bSortClasses: boolean; + bStateSave: boolean; + } + + export interface ScrollingLegacy { + bAutoCss: boolean; + bCollapse: boolean; + bInfinite: boolean; + iBarWidth: number; + iLoadGap: number; + sX: string; + sY: string; + } + + export interface RowLegacy { + nTr: Node; + _aData: any; + _aSortData: any[]; + _anHidden: Node[]; + _sRowStripe: string; + } + + export interface ColumnLegacy { + aDataSort: any; + asSorting: string[]; + bSearchable: boolean; + bSortable: boolean; + bVisible: boolean; + _bAutoType: boolean; + fnCreatedCell: FunctionColumnCreatedCell; + fnGetData: (data: any, specific: string) => any; + fnSetData: (data: any, value: any) => void; + mData: any; + mRender: any; + nTh: Node; + nIf: Node; + sClass: string; + sContentPadding: string; + sDefaultContent: string; + sName: string; + sSortDataType: string; + sSortingClass: string; + sSortingClassJUI: string; + sTitle: string; + sType: string; + sWidth: string; + sWidthOrig: string; + } + + export interface CookieCallbackLegacy { + (name: string, data: any, expires: string, path: string, cookie: string): void; + } + + export interface LanguageLegacy { + oAria?: LanguageAriaLegacy; + oPaginate?: LanguagePaginateLegacy; + sEmptyTable?: string; + sInfo?: string; + sInfoEmpty?: string; + sInfoFiltered?: string; + sInfoPostFix?: string; + sInfoThousands?: string; + sLengthMenu?: string; + sLoadingRecords?: string; + sProcessing?: string; + sSearch?: string; + sUrl?: string; + sZeroRecords?: string; + } + + export interface LanguageAriaLegacy { + sSortAscending?: string; + sSortDescending?: string; + } + + export interface LanguagePaginateLegacy { + sFirst?: string; + sLast?: string; + sNext?: string; + sPrevious?: string; + } + //#endregion "SettingsLegacy" + } \ No newline at end of file From 8fa411866ade00a2649c0c694bc609684dd58ab2 Mon Sep 17 00:00:00 2001 From: Kiarash Ghiaseddin Date: Wed, 18 Feb 2015 12:42:18 +0100 Subject: [PATCH 3/7] Add reference paths --- jquery.dataTables/jquery.dataTables-tests.ts | 3 +++ jquery.dataTables/jquery.dataTables.d.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/jquery.dataTables/jquery.dataTables-tests.ts b/jquery.dataTables/jquery.dataTables-tests.ts index 256693ab0..c90b40d09 100755 --- a/jquery.dataTables/jquery.dataTables-tests.ts +++ b/jquery.dataTables/jquery.dataTables-tests.ts @@ -1,3 +1,6 @@ +/// +/// + $(document).ready(function () { //#region "Language" diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index 7c01189f2..8d94c2e2a 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -8,6 +8,9 @@ // - Plugin and extension definitions are not typed. // - Some return types are not fully wokring + +/// + interface JQuery { DataTable(param?: DataTables.Settings): DataTables.DataTable; } From 9e571910b494d495625abfa9430c93173c592086 Mon Sep 17 00:00:00 2001 From: Kiarash Ghiaseddin Date: Wed, 25 Mar 2015 16:56:15 +0100 Subject: [PATCH 4/7] Add 'old' api Settings, new namespace is SettingsLegacy # Add 'old' api Settings, new namespace is SettingsLegacy # Fix header --- jquery.dataTables/jquery.dataTables.d.ts | 3653 +++++++++++----------- 1 file changed, 1825 insertions(+), 1828 deletions(-) diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index 8d94c2e2a..afeb01f0f 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -1,1829 +1,1826 @@ -// Type definitions for JQuery DataTables 1.10.5 -// Project: http://www.datatables.net -// Definitions by: Kiarash Ghiaseddin -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -// missing: -// - Static methods that are defined in JQueryStatic.fn are not typed. -// - Plugin and extension definitions are not typed. -// - Some return types are not fully wokring - - -/// - -interface JQuery { - DataTable(param?: DataTables.Settings): DataTables.DataTable; -} - -//TODO: Wrong, as jquery.d.ts has no interface for fn -//interface JQueryStatic { -// dataTable: DataTables.StaticFunctions; -//} - -declare module DataTables { - export interface DataTable extends DataTableCore { - /** - * Get the data for the whole table. - */ - data(): DataTable; - - /** - * Order Methods / Object - */ - order: OrderMethods; - - //#region "Cell/Cells" - - /** - * Select the cell found by a cell selector - * - * @param cellSelector Cell selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - cell(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods; - - /** - * Select the cell found by a cell selector - * - * @param rowSelector Row selector. - * @param cellSelector Cell selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - cell(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods; - - /** - * Select all cells - * - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - cells(modifier?: ObjectSelectorModifier): CellsMethods; - - /** - * Select cells found by a cell selector - * - * @param cellSelector Cell selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - cells(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods; - - /** - * Select cells found by both row and column selectors - * - * @param rowSelector Row selector. - * @param cellSelector Cell selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - cells(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods; - //#endregion "Cell/Cells" - - //#region "Column/Columns" - - /** - * Column Methods / Object - */ - column: ColumnMethodsModel; - - /** - * Columns Methods / Object - */ - columns: ColumnsMethodsModel; - - //#endregion "Column/Columns" - - //#region "Row/Rows" - - /** - * Row Methode / Object - */ - row: RowMethodsModel - - /** - * Rows Methods / Object - */ - rows: RowsMethodsModel - - //#endregion "Row/Rows" - - //#region "Table/Tables" - - /** - * Select a table based on a selector from the API's context - * - * @param tableSelector Table selector. - */ - table(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TableMethods; - - /** - * Select all tables - */ - tables(): TablesMethods; - - /** - * Select tables based on the given selector - * - * @param tableSelector Table selector. - */ - tables(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TablesMethods; - - //#endregion "Table/Tables" - } - - export interface DataTables extends DataTableCore { - [index: number]: DataTable; - } - - interface ObjectSelectorModifier { - /** - * The order modifier provides the ability to control which order the rows are processed in. - * Values: 'current', 'applied', 'index', 'original' - */ - order?: string; - - /** - * The search modifier provides the ability to govern which rows are used by the selector using the search options that are applied to the table. - * Values: 'none', 'applied', 'removed' - */ - search?: string; - - /** - * The page modifier allows you to control if the selector should consider all data in the table, regardless of paging, or if only the rows in the currently disabled page should be used. - * Values: 'all', 'current' - */ - page?: string; - } - - //#region "Namespaces" - - //#region "core-methods" - - interface DataTableCore extends UtilityMethods { - /** - * Get jquery object - */ - $(selector: string | Node | Node[]| JQuery, modifier?: ObjectSelectorModifier): JQuery; - - ///// Almost identical to $ in operation, but in this case returns the data for the matched rows. - //_(selector: string | Node | Node[] | JQuery, modifier?: ObjectSelectorModifier): JQuery; - - /** - * Ajax Methods - */ - ajax: AjaxMethodModel; - - /** - * Clear the table of all data. - */ - clear(): DataTable; - - /** - * Destroy the DataTables in the current context. - * - * @param remove Completely remove the table from the DOM (true) or leave it in the DOM in its original plain un-enhanced HTML state (default, false). - */ - destroy(remove?: boolean): DataTable; - - /** - * Destroy the DataTables in the current context. - * - * @param reset Reset (default) or hold the current paging position. A full re-sort and re-filter is performed when this method is called, which is why the pagination reset is the default action. - */ - draw(reset?: boolean): DataTable; - - /** - * Table events removal. - * - * @param event Event name to remove. - * @param callback Specific callback function to remove if you want to unbind a single event listener. - */ - off(event: string, callback?: Function): DataTable; - - /** - * Table events listener. - * - * @param event Event to listen for. - * @param callback Specific callback function to remove if you want to unbind a single event listener. - */ - on(event: string, callback: Function): DataTable; - - /** - * Listen for a table event once and then remove the listener. - * - * @param event Event to listen for. - * @param callback Specific callback function to remove if you want to unbind a single event listener. - */ - one(event: string, callback: Function): DataTable; - - /** - * Page Methods / Object - */ - page: PageMethods; - - /** - * Get current search - */ - search(): string; - - /** - * Search for data in the table. - * - * @param input Search string to apply to the table. - * @param regex Treat as a regular expression (true) or not (default, false). - * @param smart Perform smart search. - * @param caseInsen Do case-insensitive matching (default, true) or not (false). - */ - search(input: string, regex?: boolean, smart?: boolean, caseInsen?: boolean): DataTable; - - /** - * Obtain the table's settings object - */ - settings(): DataTable; - - /** - * Page Methods / Object - */ - state: StateMethods; - } - - //#region "ajax-methods" - - interface AjaxMethods extends DataTable { - /** - * Reload the table data from the Ajax data source. - * - * @param callback Function which is executed when the data as been reloaded and the table fully redrawn. - * @param resetPaging Reset (default action or true) or hold the current paging position (false). - */ - load(callback?: Function, resetPaging?: boolean): DataTable; - } - - interface AjaxMethodModel { - /** - * Get the latest JSON data obtained from the last Ajax request DataTables made - */ - json(): Object; - - /** - * Get the data submitted by DataTables to the server in the last Ajax request - */ - params(): Object; - - /** - * Reload the table data from the Ajax data source. - * - * @param callback Function which is executed when the data as been reloaded and the table fully redrawn. - * @param resetPaging Reset (default action or true) or hold the current paging position (false). - */ - reload(callback?: Function, resetPaging?: boolean): DataTable; - - /** - * Reload the table data from the Ajax data source - */ - url(): string; - - /** - * Reload the table data from the Ajax data source - * - * @param url URL to set to be the Ajax data source for the table. - */ - url(url: string): AjaxMethods; - } - - //#endregion "ajax-methods" - - //#region "order-methods" - - interface OrderMethods { - /** - * Get the ordering applied to the table. - */ - (): (string | number)[][]; - - /** - * Set the ordering applied to the table. - * - * @param order Order Model - */ - (order?: (string | number)[]): DataTable; - (order?: (string | number)[][]): DataTable; - (order: (string | number)[], ...args: any[]): DataTable; - - /** - * Add an ordering listener to an element, for a given column. - * - * @param node Selector - * @param column Column index - * @param callback Callback function - */ - listener(node: string | Node | JQuery, column: number, callback: Function): DataTable; - } - //#endregion "order-methods" - - //#region "page-methods" - - interface PageMethods { - /** - * Get the current page of the table. - */ - (): number; - - /** - * Set the current page of the table. - * - * @param page Index or 'first', 'next', 'previous', 'last' - */ - (page: number | string): DataTable; - - /** - * Get paging information about the table - */ - info(): PageMethodeModelInfoReturn; - - /** - * Get the table's page length. - */ - len(): number; - - /** - * Set the table's page length. - * - * @param length Page length to set. use -1 to show all records. - */ - len(length: number): DataTable; - } - - interface PageMethodeModelInfoReturn { - page: number; - pages: number; - start: number; - end: number; - length: number; - recordsTotal: number; - recordsDisplay: number; - } - - //#endregion "page-methods" - - //#region "state-methods" - - interface StateMethods { - /** - * Get the last saved state of the table - */ - (): StateReturnModel; - - /** - * Clear the saved state of the table. - */ - clear(): DataTable; - - /** - * Get the table state that was loaded during initialisation. - */ - loaded(): StateReturnModel; - - /** - * Trigger a state save. - */ - save(): DataTable; - } - - interface StateReturnModel { - time: number; - start: number; - length: number; - order: (string | number)[][]; - search: SearchSettings; - columns: StateReturnModelColumns[]; - } - - interface StateReturnModelColumns { - search: SearchSettings; - visible: boolean; - } - - //#endregion "state-methods" - - //#endregion "core-methods" - - //#region "util-methods" - - interface UtilityMethods { - /** - * Concatenate two or more API instances together - * - * @param a API instance to concatenate to the initial instance. - * @param b Additional API instance(s) to concatenate to the initial instance. - */ - concat(a: Object, ...b: Object[]): DataTable; - - /** - * Iterate over the contents of the API result set. - * - * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters - */ - each(fn: Function): DataTable; - - /** - * Reduce an Api instance to a single context and result set. - * - * @param idx Index to select - */ - eq(idx: number): DataTable; - - /** - * Iterate over the result set of an API instance and test each item, creating a new instance from those items which pass. - * - * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters. - */ - filter(fn: Function): DataTable; - - /** - * Flatten a 2D array structured API instance to a 1D array structure. - */ - flatten(): DataTable; - - /** - * Find the first instance of a value in the API instance's result set. - * - * @param value Value to find in the instance's result set. - */ - indexOf(value: any): number; - - /** - * Join the elements in the result set into a string. - * - * @param separator The string that will be used to separate each element of the result set. - */ - join(separator: string): string; - - /** - * Find the last instance of a value in the API instance's result set. - * - * @param value Value to find in the instance's result set. - */ - lastIndexOf(value: any): number; - - /** - * Number of elements in an API instance's result set. - */ - length: number; - - /** - * Iterate over the result set of an API instance, creating a new API instance from the values returned by the callback. - * - * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters. - */ - map(fn: Function): DataTable; - - /** - * Iterate over the result set of an API instance, creating a new API instance from the values retrieved from the original elements. - * - * @param property Object property name to use from the element in the original result set for the new result set. - */ - pluck(property: number | string): DataTable; - - /** - * Remove the last item from an API instance's result set. - */ - pop(): any; - - /** - * Add one or more items to the end of an API instance's result set. - * - * @param value_1 Item to add to the API instance's result set. - */ - push(value_1: any | any[], ...value_2: any[]): number; - - /** - * Apply a callback function against and accumulator and each element in the Api's result set (left-to-right). - * - * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters. - * @param initialValue Value to use as the first argument of the first call to the fn callback. - */ - reduce(fn: Function, initialValue?: any): any; - - /** - * Apply a callback function against and accumulator and each element in the Api's result set (right-to-left). - * - * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters. - * @param initialValue Value to use as the first argument of the first call to the fn callback. - */ - reduceRight(fn: Function, initialValue?: any): any; - - /** - * Reverse the result set of the API instance and return the original array. - */ - reverse(): DataTable; - - /** - * Remove the first item from an API instance's result set. - */ - shift(): any; - - /** - * Sort the elements of the API instance's result set. - * - * @param fn This is a standard Javascript sort comparison function. It accepts two parameters. - */ - sort(fn?: Function): DataTable; - - /** - * Modify the contents of an Api instance's result set, adding or removing items from it as required. - * - * @param index Index at which to start modifying the Api instance's result set. - * @param howMany Number of elements to remove from the result set. - * @param value_1 Item to add to the result set at the index specified by the first parameter. - */ - splice(index: number, howMany: number, value_1?: any | any[], ...value_2: any[]): any[]; - - /** - * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set. - */ - to$(): JQuery; - - /** - * Create a native Javascript array object from an API instance. - */ - toArray(): any[]; - - /** - * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set. - */ - toJQuery(): JQuery; - - /** - * Create a new API instance containing only the unique items from a the elements in an instance's result set. - */ - unique(): DataTable; - - /** - * Add one or more items to the start of an API instance's result set. - * - * @param value_1 Item to add to the API instance's result set. - */ - unshift(value_1: any | any[], ...value_2: any[]): number; - } - - //#endregion "util-methods" - - interface CommonSubMethods { - /** - * Get the DataTables cached data for the selected cell - * - * @param t Specify which cache the data should be read from. Can take one of two values: search or order - */ - cache(t: string): DataTable; - } - - //#region "cell-methods" - - interface CommonCellMethods extends CommonSubMethods { - /** - * Invalidate the data held in DataTables for the selected cells - * - * @param source Data source to read the new data from. - */ - invalidate(source?: string): DataTable; - - /** - * Get data for the selected cell - * - * @param f Data type to get. This can be one of: 'display', 'filter', 'sort', 'type' - */ - render(t: string): any; - } - - interface CellMethods extends DataTableCore, CommonCellMethods { - /** - * Get data for the selected cell - */ - data(): any; - - /** - * Get data for the selected cell - * - * @param data Value to assign to the data for the cell - */ - data(data: any): DataTable; - - /** - * Get index information about the selected cell - */ - index(): CellIndexReturn; - - /** - * Get the DOM element for the selected cell - */ - node(): Node; - } - - interface CellIndexReturn { - row: number; - column: number; - columnVisible: number; - } - - interface CellsMethods extends DataTableCore, CommonCellMethods { - /** - * Get data for the selected cells - */ - data(): DataTable; - - /** - * Get index information about the selected cells - */ - indexes(): DataTable; - - /** - * Get the DOM elements for the selected cells - */ - nodes(): DataTable; - } - //#endregion "cell-methods" - - //#region "column-methods" - - interface CommonColumnMethod extends CommonSubMethods { - /** - * Get the footer th / td cell for the selected column. - */ - footer(): any; - - /** - * Get the header th / td cell for a column. - */ - header(): Node; - - /** - * Order the table, in the direction specified, by the column selected by the column()DT selector. - * - * @param direction Direction of sort to apply to the selected column - desc (descending) or asc (ascending). - */ - order(direction: string): DataTable; - - /** - * Get the visibility of the selected column. - */ - visible(): boolean; - - /** - * Set the visibility of the selected column. - * - * @param show Specify if the column should be visible (true) or not (false). - * @param redrawCalculations Indicate if DataTables should recalculate the column layout (true - default) or not (false). Typically this would be left as the default value, but it can be useful to disable when using the method in a loop - so the calculations are performed on every call as they can hamper performance. - */ - visible(show: boolean, redrawCalculations?: boolean): DataTable; - } - - interface ColumnMethodsModel { - /** - * Select the column found by a column selector - * - * @param cellSelector Cell selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnMethods; - - /** - * Convert from the input column index type to that required. - * - * @param t The type on conversion that should take place: 'fromVisible', 'toData', 'fromData', 'toVisible' - * @param index The index to be converted - */ - index(t: string, index: number): number; - } - - interface ColumnMethods extends DataTableCore, CommonColumnMethod { - /** - * Get the data for the cells in the selected column. - */ - data(): DataTable; - - /** - * Get the data source property for the selected column - */ - dataSrc(): number | string | Function; - - /** - * Get index information about the selected cell - * - * @param t Specify if you want to get the column data index (default) or the visible index (visible). - */ - index(t?: string): DataTable; - - /** - * Obtain the th / td nodes for the selected column - */ - nodes(): DataTable[]; - } - - interface ColumnsMethodsModel { - /** - * Select all columns - * - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - (modifier?: ObjectSelectorModifier): ColumnsMethods; - - /** - * Select columns found by a cell selector - * - * @param cellSelector Cell selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnsMethods; - - /** - * Recalculate the column widths for layout. - */ - adjust(): DataTable; - } - - interface ColumnsMethods extends DataTableCore, CommonColumnMethod { - /** - * Obtain the data for the columns from the selector - */ - data(): DataTable; - - /** - * Get the data source property for the selected columns. - */ - dataSrc(): DataTable; - - /** - * Get the column indexes of the selected columns. - * - * @param t Specify if you want to get the column data index (default) or the visible index (visible). - */ - indexes(t?: string): DataTable; - - /** - * Obtain the th / td nodes for the selected columns - */ - nodes(): DataTable[][]; - } - //#endregion "column-methods" - - //#region "row-methods" - - interface CommonRowMethod extends CommonSubMethods { - /** - * Obtain the th / td nodes for the selected column - * - * @param source Data source to read the new data from. Values: 'auto', 'data', 'dom' - */ - invalidate(source?: string): DataTable; - } - - interface RowChildMethodModel { - /** - * Get the child row(s) that have been set for a parent row - */ - (): JQuery; - - /** - * Get the child row(s) that have been set for a parent row - * - * @param showRemove This parameter can be given as true or false - */ - (showRemove: boolean): RowChildMethods; - - /** - * Set the data to show in the child row(s). Note that calling this method will replace any child rows which are already attached to the parent row. - * - * @param data The data to be shown in the child row can be given in multiple different ways. - * @param className Class name that is added to the td cell node(s) of the child row(s). As of 1.10.1 it is also added to the tr row node of the child row(s). - */ - (data: (string | Node | JQuery) | (string | Node | JQuery)[], className?: string): RowChildMethods; - - /** - * Hide the child row(s) of a parent row - */ - hide(): DataTable; - - /** - * Check if the child rows of a parent row are visible - */ - isShown(): DataTable; - - /** - * Remove child row(s) from display and release any allocated memory - */ - remove(): DataTable; - - /** - * Show the child row(s) of a parent row - */ - show(): DataTable; - } - - interface RowChildMethods extends DataTableCore { - /** - * Hide the child row(s) of a parent row - */ - hide(): DataTable; - - /** - * Remove child row(s) from display and release any allocated memory - */ - remove(): DataTable; - - /** - * Make newly defined child rows visible - */ - show(): DataTable; - } - - interface RowMethodsModel { - /** - * Select a row found by a row selector - * - * @param rowSelector Row selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - (rowSelector: any, modifier?: ObjectSelectorModifier): RowMethods; - - /** - * Add a new row to the table using the given data - * - * @param data Data to use for the new row. This may be an array, object or Javascript object instance, but must be in the same format as the other data in the table - */ - add(data: any[]| Object): DataTable; - } - - interface RowMethods extends DataTableCore, CommonRowMethod { - /** - * Order Methods / Object - */ - child: RowChildMethodModel; - - /** - * Get the data for the selected row - */ - data(): any[]| Object; - - /** - * Set the data for the selected row - * - * @param d Data to use for the row. - */ - data(d: any[]| Object): DataTable; - - /** - * Get the row index of the row column. - */ - index(): number; - - /** - * Obtain the tr node for the selected row - */ - node(): Node; - - /** - * Delete the selected row from the DataTable. - */ - remove(): Node; - } - - interface RowsMethodsModel { - /** - * Select all rows - * - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - (modifier?: ObjectSelectorModifier): RowsMethods; - - /** - * Select rows found by a row selector - * - * @param cellSelector Row selector. - * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. - */ - (rowSelector: any, modifier?: ObjectSelectorModifier): RowsMethods; - - /** - * Add new rows to the table using the data given - * - * @param data Array of data elements, with each one describing a new row to be added to the table - */ - add(data: any[]): DataTable; - } - - interface RowsMethods extends DataTableCore, CommonRowMethod { - /** - * Get the data for the rows from the selector - */ - data(): DataTable; - - /** - * Set the data for the selected row - * - * @param d Data to use for the row. - */ - data(d: any[]| Object): DataTable; - - /** - * Get the row indexes of the selected rows. - */ - indexes(): DataTable; - - /** - * Obtain the tr nodes for the selected rows - */ - nodes(): DataTable; - - /** - * Delete the selected rows from the DataTable. - */ - remove(): DataTable; - } - //#endregion "row-methods" - - //#region "table-methods" - - interface TableMethods extends DataTableCore { - /** - * Get the tfoot node for the table in the API's context - */ - footer(): Node; - - /** - * Get the thead node for the table in the API's context - */ - header(): Node; - - /** - * Get the tbody node for the table in the API's context - */ - body(): Node; - - /** - * Get the div container node for the table in the API's context - */ - container(): Node; - - /** - * Get the table node for the table in the API's context - */ - node(): Node; - } - - interface TablesMethods extends DataTableCore { - /** - * Get the tfoot nodes for the tables in the API's context - */ - footer(): DataTable; - - /** - * Get the thead nodes for the tables in the API's context - */ - header(): DataTable; - - /** - * Get the tbody nodes for the tables in the API's context - */ - body(): DataTable; - - /** - * Get the div container nodes for the tables in the API's context - */ - containers(): DataTable; - - /** - * Get the table nodes for the tables in the API's context - */ - nodes(): DataTable; - } - //#endregion "table-methods" - - //#endregion "Namespaces" - - //#region "Static-Methods" - - export interface StaticFunctions { - /** - * Check is a table node is a DataTable or not - * - * @param table Selector string for table - */ - isDataTable(table: string): boolean; - - /** - * Get all DataTables on the page - * - * @param visible Get only visible tables - */ - tables(visible?: boolean): DataTables.DataTable[]; - - /** - * Version number compatibility check function - * - * @param version Version string - */ - versionCheck(version: string): boolean; - - /** - * Utils - */ - util: StaticUtilFunctions; - - /** - * Check is a table node is a DataTable or not - * - * @param table Selector string for table - */ - Api(selector: string | Node | Node[]| JQuery): DataTables.DataTable; - } - - export interface StaticUtilFunctions { - /** - * Escape special characters in a regular expression string. Since: 1.10.4 - * - * @param str String to escape - */ - escapeRegex(str: string): string; - - /** - * Throttle the calls to a method to reduce call frequency. Since: 1.10.3 - * - * @param fn Function - * @param period ms - */ - throttle(fn: Function, period?: number): Function; - } - - //#endregion "Static-Methods" - - //#region "Settings" - - export interface Settings { - - //#region "Features" - - /** - * Feature control DataTables' smart column width handling. Since: 1.10 - */ - autoWidth?: boolean; - - /** - * Feature control deferred rendering for additional speed of initialisation. Since: 1.10 - */ - deferRender?: boolean; - - /** - * Feature control table information display field. Since: 1.10 - */ - info?: boolean; - - /** - * Use markup and classes for the table to be themed by jQuery UI ThemeRoller. Since: 1.10 - */ - jQueryUI?: boolean; - - /** - * Feature control the end user's ability to change the paging display length of the table. Since: 1.10 - */ - lengthChange?: boolean; - - /** - * Feature control ordering (sorting) abilities in DataTables. Since: 1.10 - */ - ordering?: boolean; - - /** - * Enable or disable table pagination. Since: 1.10 - */ - paging?: boolean; - - /** - * Feature control the processing indicator. Since: 1.10 - */ - processing?: boolean; - - /** - * Horizontal scrolling. Since: 1.10 - */ - scrollX?: boolean; - - /** - * Vertical scrolling. Since: 1.10 Exp: "200px" - */ - scrollY?: string; - - /** - * Feature control search (filtering) abilities Since: 1.10 - */ - searching?: boolean; - - /** - * Feature control DataTables' server-side processing mode. Since: 1.10 - */ - serverSide?: boolean; - - /** - * State saving - restore table state on page reload. Since: 1.10 - */ - stateSave?: boolean; - - //#endregion "Features" - - //#region "Data" - - /** - * Load data for the table's content from an Ajax source. Since: 1.10 - */ - ajax?: string | AjaxSettings | FunctionAjax; - - /** - * Data to use as the display data for the table. Since: 1.10 - */ - data?: Object; - - //#endregion "Data" - - //#region "Options" - - /** - * Data to use as the display data for the table. Since: 1.10 - */ - columns?: ColumnSettings[]; - - /** - * Assign a column definition to one or more columns.. Since: 1.10 - */ - columnDefs?: ColumnDefsSettings[]; - - /** - * Delay the loading of server-side data until second draw - */ - deferLoading?: number | number[]; - - /** - * Destroy any existing table matching the selector and replace with the new options. Since: 1.10 - */ - destroy?: boolean; - - /** - * Initial paging start point. Since: 1.10 - */ - displayStart?: number; - - /** - * Define the table control elements to appear on the page and in what order. Since: 1.10 - */ - dom?: string; - - /** - * Change the options in the page length select list. Since: 1.10 - */ - lengthMenu?: (number | string)[]| (number | string)[][]; - - /** - * Control which cell the order event handler will be applied to in a column. Since: 1.10 - */ - orderCellsTop?: boolean; - - /** - * Highlight the columns being ordered in the table's body. Since: 1.10 - */ - orderClasses?: boolean; - - /** - * Initial order (sort) to apply to the table. Since: 1.10 - */ - order?: (string | number)[]| (string | number)[][]; - - /** - * Ordering to always be applied to the table. Since: 1.10 - */ - orderFixed?: (string | number)[]| (string | number)[][]| Object; - - /** - * Multiple column ordering ability control. Since: 1.10 - */ - orderMulti?: boolean; - - /** - * Change the initial page length (number of rows per page). Since: 1.10 - */ - pageLength?: number; - - /** - * Pagination button display options. Basic Types: simple, simple_numbers, full, full_numbers - */ - pagingType?: string; - - /** - * Retrieve an existing DataTables instance. Since: 1.10 - */ - retrieve?: boolean - - /** - * Display component renderer types. Since: 1.10 - */ - renderer?: string | RendererSettings; - - /** - * Allow the table to reduce in height when a limited number of rows are shown. Since: 1.10 - */ - scrollCollapse?: boolean; - - /** - * Set an initial filter in DataTables and / or filtering options. Since: 1.10 - */ - search?: SearchSettings; - - /** - * Define an initial search for individual columns. Since: 1.10 - */ - searchCols?: SearchSettings[]; - - /** - * Set a throttle frequency for searching. Since: 1.10 - */ - searchDelay?: number; - - /** - * Saved state validity duration. Since: 1.10 - */ - stateDuration?: number; - - /** - * Set the zebra stripe class names for the rows in the table. Since: 1.10 - */ - stripeClasses?: string[]; - - /** - * Tab index control for keyboard navigation. Since: 1.10 - */ - tabIndex?: number; - - //#endregion "Options" - - //#region "Callbacks" - - /** - * Callback for whenever a TR element is created for the table's body. Since: 1.10 - */ - createdRow?: FunctionCreateRow; - - /** - * Function that is called every time DataTables performs a draw. Since: 1.10 - */ - drawCallback?: FunctionDrawCallback; - - /** - * Footer display callback function. Since: 1.10 - */ - footerCallback?: FunctionFooterCallback; - - /** - * Number formatting callback function. Since: 1.10 - */ - formatNumber?: FunctionFormatNumber; - - /** - * Header display callback function. Since: 1.10 - */ - headerCallback?: FunctionHeaderCallback; - - /** - * Table summary information display callback. Since: 1.10 - */ - infoCallback?: FunctionInfoCallback; - - /** - * Initialisation complete callback. Since: 1.10 - */ - initComplete?: FunctionInitComplete; - - /** - * Pre-draw callback. Since: 1.10 - */ - preDrawCallback?: FunctionPreDrawCallback; - - /** - * Row draw callback.. Since: 1.10 - */ - rowCallback?: FunctionRowCallback; - - /** - * Callback that defines where and how a saved state should be loaded. Since: 1.10 - */ - stateLoadCallback?: FunctionStateLoadCallback; - - /** - * State loaded callback. Since: 1.10 - */ - stateLoaded?: FunctionStateLoaded; - - /** - * State loaded - data manipulation callback. Since: 1.10 - */ - stateLoadParams?: FunctionStateLoadParams; - - /** - * Callback that defines how the table state is stored and where. Since: 1.10 - */ - stateSaveCallback?: FunctionStateSaveCallback; - - /** - * State save - data manipulation callback. Since: 1.10 - */ - stateSaveParams?: FunctionStateSaveParams; - - //#endregion "Callbacks" - - //#region "Language" - - language?: LanguageSettings; - - //#endregion "Language" - } - - //#region "ajax-settings" - - export interface AjaxDataRequest { - draw: number; - start: number; - length: number; - data: any; - order: AjaxDataRequestOrder[]; - columns: AjaxDataRequestColumn[]; - search: AjaxDataRequestSearch; - } - - export interface AjaxDataRequestSearch { - value: string; - regex: boolean; - } - - export interface AjaxDataRequestOrder { - column: number; - dir: string; - } - - export interface AjaxDataRequestColumn { - data: string | number; - name: string; - searchable: boolean; - orderable: boolean; - search: AjaxDataRequestSearch; - } - - export interface AjaxData { - draw: number; - recordsTotal: number; - recordsFiltered: number; - data: any; - error?: string; - } - - interface AjaxSettings extends JQueryAjaxSettings { - /** - * Add or modify data submitted to the server upon an Ajax request. Since: 1.10 - */ - data?: Object | FunctionAjaxData; - - /** - * Data property or manipulation method for table data. Since: 1.10 - */ - dataSrc?: string | Function; - } - - interface FunctionAjax { - (data: Object, callback: Function, settings: SettingsLegacy): void; - } - - interface FunctionAjaxData { - (data: Object): string | Object; - } - - //#endregion "ajax-settings" - - //#region "colunm-settings" - - export interface ColumnSettings { - /** - * Cell type to be created for a column. th/td Since: 1.10 - */ - cellType?: string; - - /** - * Class to assign to each cell in the column. Since: 1.10 - */ - className?: string; - - /** - * Add padding to the text content used when calculating the optimal with for a table. Since: 1.10 - */ - contentPadding?: string; - - /** - * Cell created callback to allow DOM manipulation. Since: 1.10 - */ - createdCell?: FunctionColumnCreatedCell; - - /** - * Class to assign to each cell in the column. Since: 1.10 - */ - data?: number | string | ObjectColumnData | FunctionColumnData; - - /** - * Set default, static, content for a column. Since: 1.10 - */ - defaultContent?: string; - - /** - * Set a descriptive name for a column. Since: 1.10 - */ - name?: string; - - /** - * Enable or disable ordering on this column. Since: 1.10 - */ - orderable?: boolean; - - /** - * Define multiple column ordering as the default order for a column. Since: 1.10 - */ - orderData?: number | number[]; - - /** - * Live DOM sorting type assignment. Since: 1.10 - */ - orderDataType?: string; - - /** - * Order direction application sequence. Since: 1.10 - */ - orderSequence?: string[]; - - /** - * Render (process) the data for use in the table. Since: 1.10 - */ - render?: number | string | ObjectColumnRender | FunctionColumnRender; - - /** - * Enable or disable filtering on the data in this column. Since: 1.10 - */ - searchable?: boolean; - - /** - * Set the column title. Since: 1.10 - */ - title?: string; - - /** - * Set the column type - used for filtering and sorting string processing. Since: 1.10 - */ - type?: string; - - /** - * Enable or disable the display of this column. Since: 1.10 - */ - visible?: boolean; - - /** - * Column width assignment. Since: 1.10 - */ - width?: string; - } - - interface ColumnDefsSettings extends ColumnSettings { - targets: string | number | (number | string)[] - } - - interface FunctionColumnCreatedCell { - (cell: Node, cellData: any, rowData: any, row: number, col: number): void; - } - - interface FunctionColumnData { - (row: any, t: string, s: any, meta: Object): void; - } - - interface ObjectColumnData { - _: string; - filter?: string; - display?: string; - type?: string; - sort?: string; - } - - interface ObjectColumnRender extends ObjectColumnData { - } - - interface FunctionColumnRender { - (data: Node, t: Node, row: Node, meta: Object): void; - } - - //#endregion "colunm-settings" - - //#region "other-settings" - - export interface RendererSettings { - header?: string; - pageButton?: string; - } - - export interface SearchSettings { - /** - * Control case-sensitive filtering option. Since: 1.10 - */ - caseInsensitive?: boolean; - - /** - * Enable / disable escaping of regular expression characters in the search term. Since: 1.10 - */ - regex?: boolean; - - /** - * Enable / disable DataTables' smart filtering. Since: 1.10 - */ - smart?: boolean; - - /** - * Set an initial filtering condition on the table. Since: 1.10 - */ - search?: string; - } - - //#endregion "other-settings" - - //#region "callback-functions" - - interface FunctionCreateRow { - (row: Node, data: any[]| Object, dataIndex: number): void; - } - - interface FunctionDrawCallback { - (settings: SettingsLegacy): void; - } - - interface FunctionFooterCallback { - (tfoot: Node, data: any[], start: number, end: number, display: any[]): void; - } - - interface FunctionFormatNumber { - (formatNumber: number): void; - } - - interface FunctionHeaderCallback { - (thead: Node, data: any[], start: number, end: number, display: any[]): void; - } - - interface FunctionInfoCallback { - (settings: SettingsLegacy, start: number, end: number, mnax: number, total: number, pre: string): void; - } - - interface FunctionInitComplete { - (settings: SettingsLegacy, json: Object): void; - } - - interface FunctionPreDrawCallback { - (settings: SettingsLegacy): void; - } - - interface FunctionRowCallback { - (row: Node, data: any[]| Object): void; - } - - interface FunctionStateLoadCallback { - (settings: SettingsLegacy): void; - } - - interface FunctionStateLoaded { - (settings: SettingsLegacy, data: Object): void; - } - - interface FunctionStateLoadParams { - (settings: SettingsLegacy, data: Object): void; - } - - interface FunctionStateSaveCallback { - (settings: SettingsLegacy, data: Object): void; - } - - interface FunctionStateSaveParams { - (settings: SettingsLegacy, data: Object): void; - } - - //#endregion "callback-functions" - - //#region "language-settings" - - interface LanguageSettings { - emptyTable: string; - info: string; - infoEmpty: string; - infoFiltered: string; - infoPostFix: string; - thousands: string; - lengthMenu: string; - loadingRecords: string; - processing: string; - search: string; - zeroRecords: string; - paginate: LanguagePaginateSettings; - aria: LanguageAriaSettings; - } - - interface LanguagePaginateSettings { - first: string; - last: string; - next: string; - previous: string; - } - - interface LanguageAriaSettings { - sortAscending: string; - sortDescending: string; - } - - //#endregion "language-settings" - - //#endregion "Settings" - - //#region "SettingsLegacy" - - interface ArrayStringNode { - [index: string]: Node; - } - - export interface SettingsLegacy { - oApi: any; - oFeatures: FeaturesLegacy; - oScroll: ScrollingLegacy; - oLanguage: LanguageLegacy; // | { fnInfoCallback: FunctionInfoCallback; }; - oBrowser: { bScrollOversize: boolean; }; - aanFeatures: ArrayStringNode[][]; - aoData: RowLegacy[]; - aiDisplay: number[]; - //bServerSide: boolean; - aiDisplayMaster: number[]; - aoColumns: ColumnLegacy[]; - aoHeader: any[]; - aoFooter: any[]; - asDataSearch: string[]; - oPreviousSearch: any; - aoPreSearchCols: any[]; - aaSorting: any[][]; - aaSortingFixed: any[][]; - asStripeClasses: string[]; - asDestroyStripes: string[]; - sDestroyWidth: number; - aoRowCallback: FunctionRowCallback[]; - aoHeaderCallback: FunctionHeaderCallback[]; - aoFooterCallback: FunctionFooterCallback[]; - aoDrawCallback: FunctionDrawCallback[]; - aoRowCreatedCallback: FunctionCreateRow[]; - aoPreDrawCallback: FunctionPreDrawCallback[]; - aoInitComplete: FunctionInitComplete[]; - aoStateSaveParams: FunctionStateSaveParams[]; - aoStateLoadParams: FunctionStateLoadParams[]; - aoStateLoaded: FunctionStateLoaded[]; - sTableId: string; - nTable: Node; - nTHead: Node; - nTFoot: Node; - nTBody: Node; - nTableWrapper: Node; - bDeferLoading: boolean; - bInitialized: boolean; - aoOpenRows: any[]; - sDom: string; - sPaginationType: string; - iCookieDuration: number; - sCookiePrefix: string; - fnCookieCallback: CookieCallbackLegacy; - aoStateSave: FunctionStateSaveCallback[]; - aoStateLoad: FunctionStateLoadCallback[]; - oLoadedState: any; - sAjaxSource: string; - sAjaxDataProp: string; - bAjaxDataGet: boolean; - jqXHR: any; - fnServerData: any; - aoServerParams: any[]; - sServerMethod: string; - fnFormatNumber: FunctionFormatNumber; - aLengthMenu: any[]; - iDraw: number; - bDrawing: boolean; - iDrawError: number; - _iDisplayLength: number; - _iDisplayStart: number; - _iDisplayEnd: number; - _iRecordsTotal: number; - _iRecordsDisplay: number; - bJUI: boolean; - oClasses: any; - bFiltered: boolean; - bSorted: boolean; - bSortCellsTop: boolean; - oInit: any; - aoDestroyCallback: any[]; - fnRecordsTotal: () => number; - fnRecordsDisplay: () => number; - fnDisplayEnd: () => number; - oInstance: any; - sInstance: string; - iTabIndex: number; - nScrollHead: Node; - nScrollFoot: Node; - } - - export interface FeaturesLegacy { - bAutoWidth: boolean; - bDeferRender: boolean; - bFilter: boolean; - bInfo: boolean; - bLengthChange: boolean; - bPaginate: boolean; - bProcessing: boolean; - bServerSide: boolean; - bSort: boolean; - bSortClasses: boolean; - bStateSave: boolean; - } - - export interface ScrollingLegacy { - bAutoCss: boolean; - bCollapse: boolean; - bInfinite: boolean; - iBarWidth: number; - iLoadGap: number; - sX: string; - sY: string; - } - - export interface RowLegacy { - nTr: Node; - _aData: any; - _aSortData: any[]; - _anHidden: Node[]; - _sRowStripe: string; - } - - export interface ColumnLegacy { - aDataSort: any; - asSorting: string[]; - bSearchable: boolean; - bSortable: boolean; - bVisible: boolean; - _bAutoType: boolean; - fnCreatedCell: FunctionColumnCreatedCell; - fnGetData: (data: any, specific: string) => any; - fnSetData: (data: any, value: any) => void; - mData: any; - mRender: any; - nTh: Node; - nIf: Node; - sClass: string; - sContentPadding: string; - sDefaultContent: string; - sName: string; - sSortDataType: string; - sSortingClass: string; - sSortingClassJUI: string; - sTitle: string; - sType: string; - sWidth: string; - sWidthOrig: string; - } - - export interface CookieCallbackLegacy { - (name: string, data: any, expires: string, path: string, cookie: string): void; - } - - export interface LanguageLegacy { - oAria?: LanguageAriaLegacy; - oPaginate?: LanguagePaginateLegacy; - sEmptyTable?: string; - sInfo?: string; - sInfoEmpty?: string; - sInfoFiltered?: string; - sInfoPostFix?: string; - sInfoThousands?: string; - sLengthMenu?: string; - sLoadingRecords?: string; - sProcessing?: string; - sSearch?: string; - sUrl?: string; - sZeroRecords?: string; - } - - export interface LanguageAriaLegacy { - sSortAscending?: string; - sSortDescending?: string; - } - - export interface LanguagePaginateLegacy { - sFirst?: string; - sLast?: string; - sNext?: string; - sPrevious?: string; - } - //#endregion "SettingsLegacy" - +// Type definitions for JQuery DataTables 1.10.5 +// Project: http://www.datatables.net +// Definitions by: Kiarash Ghiaseddin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// missing: +// - Static methods that are defined in JQueryStatic.fn are not typed. +// - Plugin and extension definitions are not typed. +// - Some return types are not fully wokring + +interface JQuery { + DataTable(param?: DataTables.Settings): DataTables.DataTable; +} + +//TODO: Wrong, as jquery.d.ts has no interface for fn +//interface JQueryStatic { +// dataTable: DataTables.StaticFunctions; +//} + +declare module DataTables { + export interface DataTable extends DataTableCore { + /** + * Get the data for the whole table. + */ + data(): DataTable; + + /** + * Order Methods / Object + */ + order: OrderMethods; + + //#region "Cell/Cells" + + /** + * Select the cell found by a cell selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cell(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods; + + /** + * Select the cell found by a cell selector + * + * @param rowSelector Row selector. + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cell(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellMethods; + + /** + * Select all cells + * + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cells(modifier?: ObjectSelectorModifier): CellsMethods; + + /** + * Select cells found by a cell selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cells(cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods; + + /** + * Select cells found by both row and column selectors + * + * @param rowSelector Row selector. + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + cells(rowSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], cellSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[], modifier?: ObjectSelectorModifier): CellsMethods; + //#endregion "Cell/Cells" + + //#region "Column/Columns" + + /** + * Column Methods / Object + */ + column: ColumnMethodsModel; + + /** + * Columns Methods / Object + */ + columns: ColumnsMethodsModel; + + //#endregion "Column/Columns" + + //#region "Row/Rows" + + /** + * Row Methode / Object + */ + row: RowMethodsModel + + /** + * Rows Methods / Object + */ + rows: RowsMethodsModel + + //#endregion "Row/Rows" + + //#region "Table/Tables" + + /** + * Select a table based on a selector from the API's context + * + * @param tableSelector Table selector. + */ + table(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TableMethods; + + /** + * Select all tables + */ + tables(): TablesMethods; + + /** + * Select tables based on the given selector + * + * @param tableSelector Table selector. + */ + tables(tableSelector: (string | Node | Function | JQuery | Object) | (string | Node | Function | JQuery | Object)[]): TablesMethods; + + //#endregion "Table/Tables" + } + + export interface DataTables extends DataTableCore { + [index: number]: DataTable; + } + + interface ObjectSelectorModifier { + /** + * The order modifier provides the ability to control which order the rows are processed in. + * Values: 'current', 'applied', 'index', 'original' + */ + order?: string; + + /** + * The search modifier provides the ability to govern which rows are used by the selector using the search options that are applied to the table. + * Values: 'none', 'applied', 'removed' + */ + search?: string; + + /** + * The page modifier allows you to control if the selector should consider all data in the table, regardless of paging, or if only the rows in the currently disabled page should be used. + * Values: 'all', 'current' + */ + page?: string; + } + + //#region "Namespaces" + + //#region "core-methods" + + interface DataTableCore extends UtilityMethods { + /** + * Get jquery object + */ + $(selector: string | Node | Node[]| JQuery, modifier?: ObjectSelectorModifier): JQuery; + + ///// Almost identical to $ in operation, but in this case returns the data for the matched rows. + //_(selector: string | Node | Node[] | JQuery, modifier?: ObjectSelectorModifier): JQuery; + + /** + * Ajax Methods + */ + ajax: AjaxMethodModel; + + /** + * Clear the table of all data. + */ + clear(): DataTable; + + /** + * Destroy the DataTables in the current context. + * + * @param remove Completely remove the table from the DOM (true) or leave it in the DOM in its original plain un-enhanced HTML state (default, false). + */ + destroy(remove?: boolean): DataTable; + + /** + * Destroy the DataTables in the current context. + * + * @param reset Reset (default) or hold the current paging position. A full re-sort and re-filter is performed when this method is called, which is why the pagination reset is the default action. + */ + draw(reset?: boolean): DataTable; + + /** + * Table events removal. + * + * @param event Event name to remove. + * @param callback Specific callback function to remove if you want to unbind a single event listener. + */ + off(event: string, callback?: Function): DataTable; + + /** + * Table events listener. + * + * @param event Event to listen for. + * @param callback Specific callback function to remove if you want to unbind a single event listener. + */ + on(event: string, callback: Function): DataTable; + + /** + * Listen for a table event once and then remove the listener. + * + * @param event Event to listen for. + * @param callback Specific callback function to remove if you want to unbind a single event listener. + */ + one(event: string, callback: Function): DataTable; + + /** + * Page Methods / Object + */ + page: PageMethods; + + /** + * Get current search + */ + search(): string; + + /** + * Search for data in the table. + * + * @param input Search string to apply to the table. + * @param regex Treat as a regular expression (true) or not (default, false). + * @param smart Perform smart search. + * @param caseInsen Do case-insensitive matching (default, true) or not (false). + */ + search(input: string, regex?: boolean, smart?: boolean, caseInsen?: boolean): DataTable; + + /** + * Obtain the table's settings object + */ + settings(): DataTable; + + /** + * Page Methods / Object + */ + state: StateMethods; + } + + //#region "ajax-methods" + + interface AjaxMethods extends DataTable { + /** + * Reload the table data from the Ajax data source. + * + * @param callback Function which is executed when the data as been reloaded and the table fully redrawn. + * @param resetPaging Reset (default action or true) or hold the current paging position (false). + */ + load(callback?: Function, resetPaging?: boolean): DataTable; + } + + interface AjaxMethodModel { + /** + * Get the latest JSON data obtained from the last Ajax request DataTables made + */ + json(): Object; + + /** + * Get the data submitted by DataTables to the server in the last Ajax request + */ + params(): Object; + + /** + * Reload the table data from the Ajax data source. + * + * @param callback Function which is executed when the data as been reloaded and the table fully redrawn. + * @param resetPaging Reset (default action or true) or hold the current paging position (false). + */ + reload(callback?: Function, resetPaging?: boolean): DataTable; + + /** + * Reload the table data from the Ajax data source + */ + url(): string; + + /** + * Reload the table data from the Ajax data source + * + * @param url URL to set to be the Ajax data source for the table. + */ + url(url: string): AjaxMethods; + } + + //#endregion "ajax-methods" + + //#region "order-methods" + + interface OrderMethods { + /** + * Get the ordering applied to the table. + */ + (): (string | number)[][]; + + /** + * Set the ordering applied to the table. + * + * @param order Order Model + */ + (order?: (string | number)[]): DataTable; + (order?: (string | number)[][]): DataTable; + (order: (string | number)[], ...args: any[]): DataTable; + + /** + * Add an ordering listener to an element, for a given column. + * + * @param node Selector + * @param column Column index + * @param callback Callback function + */ + listener(node: string | Node | JQuery, column: number, callback: Function): DataTable; + } + //#endregion "order-methods" + + //#region "page-methods" + + interface PageMethods { + /** + * Get the current page of the table. + */ + (): number; + + /** + * Set the current page of the table. + * + * @param page Index or 'first', 'next', 'previous', 'last' + */ + (page: number | string): DataTable; + + /** + * Get paging information about the table + */ + info(): PageMethodeModelInfoReturn; + + /** + * Get the table's page length. + */ + len(): number; + + /** + * Set the table's page length. + * + * @param length Page length to set. use -1 to show all records. + */ + len(length: number): DataTable; + } + + interface PageMethodeModelInfoReturn { + page: number; + pages: number; + start: number; + end: number; + length: number; + recordsTotal: number; + recordsDisplay: number; + } + + //#endregion "page-methods" + + //#region "state-methods" + + interface StateMethods { + /** + * Get the last saved state of the table + */ + (): StateReturnModel; + + /** + * Clear the saved state of the table. + */ + clear(): DataTable; + + /** + * Get the table state that was loaded during initialisation. + */ + loaded(): StateReturnModel; + + /** + * Trigger a state save. + */ + save(): DataTable; + } + + interface StateReturnModel { + time: number; + start: number; + length: number; + order: (string | number)[][]; + search: SearchSettings; + columns: StateReturnModelColumns[]; + } + + interface StateReturnModelColumns { + search: SearchSettings; + visible: boolean; + } + + //#endregion "state-methods" + + //#endregion "core-methods" + + //#region "util-methods" + + interface UtilityMethods { + /** + * Concatenate two or more API instances together + * + * @param a API instance to concatenate to the initial instance. + * @param b Additional API instance(s) to concatenate to the initial instance. + */ + concat(a: Object, ...b: Object[]): DataTable; + + /** + * Iterate over the contents of the API result set. + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters + */ + each(fn: Function): DataTable; + + /** + * Reduce an Api instance to a single context and result set. + * + * @param idx Index to select + */ + eq(idx: number): DataTable; + + /** + * Iterate over the result set of an API instance and test each item, creating a new instance from those items which pass. + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters. + */ + filter(fn: Function): DataTable; + + /** + * Flatten a 2D array structured API instance to a 1D array structure. + */ + flatten(): DataTable; + + /** + * Find the first instance of a value in the API instance's result set. + * + * @param value Value to find in the instance's result set. + */ + indexOf(value: any): number; + + /** + * Join the elements in the result set into a string. + * + * @param separator The string that will be used to separate each element of the result set. + */ + join(separator: string): string; + + /** + * Find the last instance of a value in the API instance's result set. + * + * @param value Value to find in the instance's result set. + */ + lastIndexOf(value: any): number; + + /** + * Number of elements in an API instance's result set. + */ + length: number; + + /** + * Iterate over the result set of an API instance, creating a new API instance from the values returned by the callback. + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with three parameters. + */ + map(fn: Function): DataTable; + + /** + * Iterate over the result set of an API instance, creating a new API instance from the values retrieved from the original elements. + * + * @param property Object property name to use from the element in the original result set for the new result set. + */ + pluck(property: number | string): DataTable; + + /** + * Remove the last item from an API instance's result set. + */ + pop(): any; + + /** + * Add one or more items to the end of an API instance's result set. + * + * @param value_1 Item to add to the API instance's result set. + */ + push(value_1: any | any[], ...value_2: any[]): number; + + /** + * Apply a callback function against and accumulator and each element in the Api's result set (left-to-right). + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters. + * @param initialValue Value to use as the first argument of the first call to the fn callback. + */ + reduce(fn: Function, initialValue?: any): any; + + /** + * Apply a callback function against and accumulator and each element in the Api's result set (right-to-left). + * + * @param fn Callback function which is called for each item in the API instance result set. The callback is called with four parameters. + * @param initialValue Value to use as the first argument of the first call to the fn callback. + */ + reduceRight(fn: Function, initialValue?: any): any; + + /** + * Reverse the result set of the API instance and return the original array. + */ + reverse(): DataTable; + + /** + * Remove the first item from an API instance's result set. + */ + shift(): any; + + /** + * Sort the elements of the API instance's result set. + * + * @param fn This is a standard Javascript sort comparison function. It accepts two parameters. + */ + sort(fn?: Function): DataTable; + + /** + * Modify the contents of an Api instance's result set, adding or removing items from it as required. + * + * @param index Index at which to start modifying the Api instance's result set. + * @param howMany Number of elements to remove from the result set. + * @param value_1 Item to add to the result set at the index specified by the first parameter. + */ + splice(index: number, howMany: number, value_1?: any | any[], ...value_2: any[]): any[]; + + /** + * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set. + */ + to$(): JQuery; + + /** + * Create a native Javascript array object from an API instance. + */ + toArray(): any[]; + + /** + * Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set. + */ + toJQuery(): JQuery; + + /** + * Create a new API instance containing only the unique items from a the elements in an instance's result set. + */ + unique(): DataTable; + + /** + * Add one or more items to the start of an API instance's result set. + * + * @param value_1 Item to add to the API instance's result set. + */ + unshift(value_1: any | any[], ...value_2: any[]): number; + } + + //#endregion "util-methods" + + interface CommonSubMethods { + /** + * Get the DataTables cached data for the selected cell + * + * @param t Specify which cache the data should be read from. Can take one of two values: search or order + */ + cache(t: string): DataTable; + } + + //#region "cell-methods" + + interface CommonCellMethods extends CommonSubMethods { + /** + * Invalidate the data held in DataTables for the selected cells + * + * @param source Data source to read the new data from. + */ + invalidate(source?: string): DataTable; + + /** + * Get data for the selected cell + * + * @param f Data type to get. This can be one of: 'display', 'filter', 'sort', 'type' + */ + render(t: string): any; + } + + interface CellMethods extends DataTableCore, CommonCellMethods { + /** + * Get data for the selected cell + */ + data(): any; + + /** + * Get data for the selected cell + * + * @param data Value to assign to the data for the cell + */ + data(data: any): DataTable; + + /** + * Get index information about the selected cell + */ + index(): CellIndexReturn; + + /** + * Get the DOM element for the selected cell + */ + node(): Node; + } + + interface CellIndexReturn { + row: number; + column: number; + columnVisible: number; + } + + interface CellsMethods extends DataTableCore, CommonCellMethods { + /** + * Get data for the selected cells + */ + data(): DataTable; + + /** + * Get index information about the selected cells + */ + indexes(): DataTable; + + /** + * Get the DOM elements for the selected cells + */ + nodes(): DataTable; + } + //#endregion "cell-methods" + + //#region "column-methods" + + interface CommonColumnMethod extends CommonSubMethods { + /** + * Get the footer th / td cell for the selected column. + */ + footer(): any; + + /** + * Get the header th / td cell for a column. + */ + header(): Node; + + /** + * Order the table, in the direction specified, by the column selected by the column()DT selector. + * + * @param direction Direction of sort to apply to the selected column - desc (descending) or asc (ascending). + */ + order(direction: string): DataTable; + + /** + * Get the visibility of the selected column. + */ + visible(): boolean; + + /** + * Set the visibility of the selected column. + * + * @param show Specify if the column should be visible (true) or not (false). + * @param redrawCalculations Indicate if DataTables should recalculate the column layout (true - default) or not (false). Typically this would be left as the default value, but it can be useful to disable when using the method in a loop - so the calculations are performed on every call as they can hamper performance. + */ + visible(show: boolean, redrawCalculations?: boolean): DataTable; + } + + interface ColumnMethodsModel { + /** + * Select the column found by a column selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnMethods; + + /** + * Convert from the input column index type to that required. + * + * @param t The type on conversion that should take place: 'fromVisible', 'toData', 'fromData', 'toVisible' + * @param index The index to be converted + */ + index(t: string, index: number): number; + } + + interface ColumnMethods extends DataTableCore, CommonColumnMethod { + /** + * Get the data for the cells in the selected column. + */ + data(): DataTable; + + /** + * Get the data source property for the selected column + */ + dataSrc(): number | string | Function; + + /** + * Get index information about the selected cell + * + * @param t Specify if you want to get the column data index (default) or the visible index (visible). + */ + index(t?: string): DataTable; + + /** + * Obtain the th / td nodes for the selected column + */ + nodes(): DataTable[]; + } + + interface ColumnsMethodsModel { + /** + * Select all columns + * + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (modifier?: ObjectSelectorModifier): ColumnsMethods; + + /** + * Select columns found by a cell selector + * + * @param cellSelector Cell selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (columnSelector: any, modifier?: ObjectSelectorModifier): ColumnsMethods; + + /** + * Recalculate the column widths for layout. + */ + adjust(): DataTable; + } + + interface ColumnsMethods extends DataTableCore, CommonColumnMethod { + /** + * Obtain the data for the columns from the selector + */ + data(): DataTable; + + /** + * Get the data source property for the selected columns. + */ + dataSrc(): DataTable; + + /** + * Get the column indexes of the selected columns. + * + * @param t Specify if you want to get the column data index (default) or the visible index (visible). + */ + indexes(t?: string): DataTable; + + /** + * Obtain the th / td nodes for the selected columns + */ + nodes(): DataTable[][]; + } + //#endregion "column-methods" + + //#region "row-methods" + + interface CommonRowMethod extends CommonSubMethods { + /** + * Obtain the th / td nodes for the selected column + * + * @param source Data source to read the new data from. Values: 'auto', 'data', 'dom' + */ + invalidate(source?: string): DataTable; + } + + interface RowChildMethodModel { + /** + * Get the child row(s) that have been set for a parent row + */ + (): JQuery; + + /** + * Get the child row(s) that have been set for a parent row + * + * @param showRemove This parameter can be given as true or false + */ + (showRemove: boolean): RowChildMethods; + + /** + * Set the data to show in the child row(s). Note that calling this method will replace any child rows which are already attached to the parent row. + * + * @param data The data to be shown in the child row can be given in multiple different ways. + * @param className Class name that is added to the td cell node(s) of the child row(s). As of 1.10.1 it is also added to the tr row node of the child row(s). + */ + (data: (string | Node | JQuery) | (string | Node | JQuery)[], className?: string): RowChildMethods; + + /** + * Hide the child row(s) of a parent row + */ + hide(): DataTable; + + /** + * Check if the child rows of a parent row are visible + */ + isShown(): DataTable; + + /** + * Remove child row(s) from display and release any allocated memory + */ + remove(): DataTable; + + /** + * Show the child row(s) of a parent row + */ + show(): DataTable; + } + + interface RowChildMethods extends DataTableCore { + /** + * Hide the child row(s) of a parent row + */ + hide(): DataTable; + + /** + * Remove child row(s) from display and release any allocated memory + */ + remove(): DataTable; + + /** + * Make newly defined child rows visible + */ + show(): DataTable; + } + + interface RowMethodsModel { + /** + * Select a row found by a row selector + * + * @param rowSelector Row selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (rowSelector: any, modifier?: ObjectSelectorModifier): RowMethods; + + /** + * Add a new row to the table using the given data + * + * @param data Data to use for the new row. This may be an array, object or Javascript object instance, but must be in the same format as the other data in the table + */ + add(data: any[]| Object): DataTable; + } + + interface RowMethods extends DataTableCore, CommonRowMethod { + /** + * Order Methods / Object + */ + child: RowChildMethodModel; + + /** + * Get the data for the selected row + */ + data(): any[]| Object; + + /** + * Set the data for the selected row + * + * @param d Data to use for the row. + */ + data(d: any[]| Object): DataTable; + + /** + * Get the row index of the row column. + */ + index(): number; + + /** + * Obtain the tr node for the selected row + */ + node(): Node; + + /** + * Delete the selected row from the DataTable. + */ + remove(): Node; + } + + interface RowsMethodsModel { + /** + * Select all rows + * + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (modifier?: ObjectSelectorModifier): RowsMethods; + + /** + * Select rows found by a row selector + * + * @param cellSelector Row selector. + * @param Option used to specify how the cells should be ordered, and if paging or filtering in the table should be taken into account. + */ + (rowSelector: any, modifier?: ObjectSelectorModifier): RowsMethods; + + /** + * Add new rows to the table using the data given + * + * @param data Array of data elements, with each one describing a new row to be added to the table + */ + add(data: any[]): DataTable; + } + + interface RowsMethods extends DataTableCore, CommonRowMethod { + /** + * Get the data for the rows from the selector + */ + data(): DataTable; + + /** + * Set the data for the selected row + * + * @param d Data to use for the row. + */ + data(d: any[]| Object): DataTable; + + /** + * Get the row indexes of the selected rows. + */ + indexes(): DataTable; + + /** + * Obtain the tr nodes for the selected rows + */ + nodes(): DataTable; + + /** + * Delete the selected rows from the DataTable. + */ + remove(): DataTable; + } + //#endregion "row-methods" + + //#region "table-methods" + + interface TableMethods extends DataTableCore { + /** + * Get the tfoot node for the table in the API's context + */ + footer(): Node; + + /** + * Get the thead node for the table in the API's context + */ + header(): Node; + + /** + * Get the tbody node for the table in the API's context + */ + body(): Node; + + /** + * Get the div container node for the table in the API's context + */ + container(): Node; + + /** + * Get the table node for the table in the API's context + */ + node(): Node; + } + + interface TablesMethods extends DataTableCore { + /** + * Get the tfoot nodes for the tables in the API's context + */ + footer(): DataTable; + + /** + * Get the thead nodes for the tables in the API's context + */ + header(): DataTable; + + /** + * Get the tbody nodes for the tables in the API's context + */ + body(): DataTable; + + /** + * Get the div container nodes for the tables in the API's context + */ + containers(): DataTable; + + /** + * Get the table nodes for the tables in the API's context + */ + nodes(): DataTable; + } + //#endregion "table-methods" + + //#endregion "Namespaces" + + //#region "Static-Methods" + + export interface StaticFunctions { + /** + * Check is a table node is a DataTable or not + * + * @param table Selector string for table + */ + isDataTable(table: string): boolean; + + /** + * Get all DataTables on the page + * + * @param visible Get only visible tables + */ + tables(visible?: boolean): DataTables.DataTable[]; + + /** + * Version number compatibility check function + * + * @param version Version string + */ + versionCheck(version: string): boolean; + + /** + * Utils + */ + util: StaticUtilFunctions; + + /** + * Check is a table node is a DataTable or not + * + * @param table Selector string for table + */ + Api(selector: string | Node | Node[]| JQuery): DataTables.DataTable; + } + + export interface StaticUtilFunctions { + /** + * Escape special characters in a regular expression string. Since: 1.10.4 + * + * @param str String to escape + */ + escapeRegex(str: string): string; + + /** + * Throttle the calls to a method to reduce call frequency. Since: 1.10.3 + * + * @param fn Function + * @param period ms + */ + throttle(fn: Function, period?: number): Function; + } + + //#endregion "Static-Methods" + + //#region "Settings" + + export interface Settings { + + //#region "Features" + + /** + * Feature control DataTables' smart column width handling. Since: 1.10 + */ + autoWidth?: boolean; + + /** + * Feature control deferred rendering for additional speed of initialisation. Since: 1.10 + */ + deferRender?: boolean; + + /** + * Feature control table information display field. Since: 1.10 + */ + info?: boolean; + + /** + * Use markup and classes for the table to be themed by jQuery UI ThemeRoller. Since: 1.10 + */ + jQueryUI?: boolean; + + /** + * Feature control the end user's ability to change the paging display length of the table. Since: 1.10 + */ + lengthChange?: boolean; + + /** + * Feature control ordering (sorting) abilities in DataTables. Since: 1.10 + */ + ordering?: boolean; + + /** + * Enable or disable table pagination. Since: 1.10 + */ + paging?: boolean; + + /** + * Feature control the processing indicator. Since: 1.10 + */ + processing?: boolean; + + /** + * Horizontal scrolling. Since: 1.10 + */ + scrollX?: boolean; + + /** + * Vertical scrolling. Since: 1.10 Exp: "200px" + */ + scrollY?: string; + + /** + * Feature control search (filtering) abilities Since: 1.10 + */ + searching?: boolean; + + /** + * Feature control DataTables' server-side processing mode. Since: 1.10 + */ + serverSide?: boolean; + + /** + * State saving - restore table state on page reload. Since: 1.10 + */ + stateSave?: boolean; + + //#endregion "Features" + + //#region "Data" + + /** + * Load data for the table's content from an Ajax source. Since: 1.10 + */ + ajax?: string | AjaxSettings | FunctionAjax; + + /** + * Data to use as the display data for the table. Since: 1.10 + */ + data?: Object; + + //#endregion "Data" + + //#region "Options" + + /** + * Data to use as the display data for the table. Since: 1.10 + */ + columns?: ColumnSettings[]; + + /** + * Assign a column definition to one or more columns.. Since: 1.10 + */ + columnDefs?: ColumnDefsSettings[]; + + /** + * Delay the loading of server-side data until second draw + */ + deferLoading?: number | number[]; + + /** + * Destroy any existing table matching the selector and replace with the new options. Since: 1.10 + */ + destroy?: boolean; + + /** + * Initial paging start point. Since: 1.10 + */ + displayStart?: number; + + /** + * Define the table control elements to appear on the page and in what order. Since: 1.10 + */ + dom?: string; + + /** + * Change the options in the page length select list. Since: 1.10 + */ + lengthMenu?: (number | string)[]| (number | string)[][]; + + /** + * Control which cell the order event handler will be applied to in a column. Since: 1.10 + */ + orderCellsTop?: boolean; + + /** + * Highlight the columns being ordered in the table's body. Since: 1.10 + */ + orderClasses?: boolean; + + /** + * Initial order (sort) to apply to the table. Since: 1.10 + */ + order?: (string | number)[]| (string | number)[][]; + + /** + * Ordering to always be applied to the table. Since: 1.10 + */ + orderFixed?: (string | number)[]| (string | number)[][]| Object; + + /** + * Multiple column ordering ability control. Since: 1.10 + */ + orderMulti?: boolean; + + /** + * Change the initial page length (number of rows per page). Since: 1.10 + */ + pageLength?: number; + + /** + * Pagination button display options. Basic Types: simple, simple_numbers, full, full_numbers + */ + pagingType?: string; + + /** + * Retrieve an existing DataTables instance. Since: 1.10 + */ + retrieve?: boolean + + /** + * Display component renderer types. Since: 1.10 + */ + renderer?: string | RendererSettings; + + /** + * Allow the table to reduce in height when a limited number of rows are shown. Since: 1.10 + */ + scrollCollapse?: boolean; + + /** + * Set an initial filter in DataTables and / or filtering options. Since: 1.10 + */ + search?: SearchSettings; + + /** + * Define an initial search for individual columns. Since: 1.10 + */ + searchCols?: SearchSettings[]; + + /** + * Set a throttle frequency for searching. Since: 1.10 + */ + searchDelay?: number; + + /** + * Saved state validity duration. Since: 1.10 + */ + stateDuration?: number; + + /** + * Set the zebra stripe class names for the rows in the table. Since: 1.10 + */ + stripeClasses?: string[]; + + /** + * Tab index control for keyboard navigation. Since: 1.10 + */ + tabIndex?: number; + + //#endregion "Options" + + //#region "Callbacks" + + /** + * Callback for whenever a TR element is created for the table's body. Since: 1.10 + */ + createdRow?: FunctionCreateRow; + + /** + * Function that is called every time DataTables performs a draw. Since: 1.10 + */ + drawCallback?: FunctionDrawCallback; + + /** + * Footer display callback function. Since: 1.10 + */ + footerCallback?: FunctionFooterCallback; + + /** + * Number formatting callback function. Since: 1.10 + */ + formatNumber?: FunctionFormatNumber; + + /** + * Header display callback function. Since: 1.10 + */ + headerCallback?: FunctionHeaderCallback; + + /** + * Table summary information display callback. Since: 1.10 + */ + infoCallback?: FunctionInfoCallback; + + /** + * Initialisation complete callback. Since: 1.10 + */ + initComplete?: FunctionInitComplete; + + /** + * Pre-draw callback. Since: 1.10 + */ + preDrawCallback?: FunctionPreDrawCallback; + + /** + * Row draw callback.. Since: 1.10 + */ + rowCallback?: FunctionRowCallback; + + /** + * Callback that defines where and how a saved state should be loaded. Since: 1.10 + */ + stateLoadCallback?: FunctionStateLoadCallback; + + /** + * State loaded callback. Since: 1.10 + */ + stateLoaded?: FunctionStateLoaded; + + /** + * State loaded - data manipulation callback. Since: 1.10 + */ + stateLoadParams?: FunctionStateLoadParams; + + /** + * Callback that defines how the table state is stored and where. Since: 1.10 + */ + stateSaveCallback?: FunctionStateSaveCallback; + + /** + * State save - data manipulation callback. Since: 1.10 + */ + stateSaveParams?: FunctionStateSaveParams; + + //#endregion "Callbacks" + + //#region "Language" + + language?: LanguageSettings; + + //#endregion "Language" + } + + //#region "ajax-settings" + + export interface AjaxDataRequest { + draw: number; + start: number; + length: number; + data: any; + order: AjaxDataRequestOrder[]; + columns: AjaxDataRequestColumn[]; + search: AjaxDataRequestSearch; + } + + export interface AjaxDataRequestSearch { + value: string; + regex: boolean; + } + + export interface AjaxDataRequestOrder { + column: number; + dir: string; + } + + export interface AjaxDataRequestColumn { + data: string | number; + name: string; + searchable: boolean; + orderable: boolean; + search: AjaxDataRequestSearch; + } + + export interface AjaxData { + draw: number; + recordsTotal: number; + recordsFiltered: number; + data: any; + error?: string; + } + + interface AjaxSettings extends JQueryAjaxSettings { + /** + * Add or modify data submitted to the server upon an Ajax request. Since: 1.10 + */ + data?: Object | FunctionAjaxData; + + /** + * Data property or manipulation method for table data. Since: 1.10 + */ + dataSrc?: string | Function; + } + + interface FunctionAjax { + (data: Object, callback: Function, settings: SettingsLegacy): void; + } + + interface FunctionAjaxData { + (data: Object): string | Object; + } + + //#endregion "ajax-settings" + + //#region "colunm-settings" + + export interface ColumnSettings { + /** + * Cell type to be created for a column. th/td Since: 1.10 + */ + cellType?: string; + + /** + * Class to assign to each cell in the column. Since: 1.10 + */ + className?: string; + + /** + * Add padding to the text content used when calculating the optimal with for a table. Since: 1.10 + */ + contentPadding?: string; + + /** + * Cell created callback to allow DOM manipulation. Since: 1.10 + */ + createdCell?: FunctionColumnCreatedCell; + + /** + * Class to assign to each cell in the column. Since: 1.10 + */ + data?: number | string | ObjectColumnData | FunctionColumnData; + + /** + * Set default, static, content for a column. Since: 1.10 + */ + defaultContent?: string; + + /** + * Set a descriptive name for a column. Since: 1.10 + */ + name?: string; + + /** + * Enable or disable ordering on this column. Since: 1.10 + */ + orderable?: boolean; + + /** + * Define multiple column ordering as the default order for a column. Since: 1.10 + */ + orderData?: number | number[]; + + /** + * Live DOM sorting type assignment. Since: 1.10 + */ + orderDataType?: string; + + /** + * Order direction application sequence. Since: 1.10 + */ + orderSequence?: string[]; + + /** + * Render (process) the data for use in the table. Since: 1.10 + */ + render?: number | string | ObjectColumnRender | FunctionColumnRender; + + /** + * Enable or disable filtering on the data in this column. Since: 1.10 + */ + searchable?: boolean; + + /** + * Set the column title. Since: 1.10 + */ + title?: string; + + /** + * Set the column type - used for filtering and sorting string processing. Since: 1.10 + */ + type?: string; + + /** + * Enable or disable the display of this column. Since: 1.10 + */ + visible?: boolean; + + /** + * Column width assignment. Since: 1.10 + */ + width?: string; + } + + interface ColumnDefsSettings extends ColumnSettings { + targets: string | number | (number | string)[] + } + + interface FunctionColumnCreatedCell { + (cell: Node, cellData: any, rowData: any, row: number, col: number): void; + } + + interface FunctionColumnData { + (row: any, t: string, s: any, meta: Object): void; + } + + interface ObjectColumnData { + _: string; + filter?: string; + display?: string; + type?: string; + sort?: string; + } + + interface ObjectColumnRender extends ObjectColumnData { + } + + interface FunctionColumnRender { + (data: Node, t: Node, row: Node, meta: Object): void; + } + + //#endregion "colunm-settings" + + //#region "other-settings" + + export interface RendererSettings { + header?: string; + pageButton?: string; + } + + export interface SearchSettings { + /** + * Control case-sensitive filtering option. Since: 1.10 + */ + caseInsensitive?: boolean; + + /** + * Enable / disable escaping of regular expression characters in the search term. Since: 1.10 + */ + regex?: boolean; + + /** + * Enable / disable DataTables' smart filtering. Since: 1.10 + */ + smart?: boolean; + + /** + * Set an initial filtering condition on the table. Since: 1.10 + */ + search?: string; + } + + //#endregion "other-settings" + + //#region "callback-functions" + + interface FunctionCreateRow { + (row: Node, data: any[]| Object, dataIndex: number): void; + } + + interface FunctionDrawCallback { + (settings: SettingsLegacy): void; + } + + interface FunctionFooterCallback { + (tfoot: Node, data: any[], start: number, end: number, display: any[]): void; + } + + interface FunctionFormatNumber { + (formatNumber: number): void; + } + + interface FunctionHeaderCallback { + (thead: Node, data: any[], start: number, end: number, display: any[]): void; + } + + interface FunctionInfoCallback { + (settings: SettingsLegacy, start: number, end: number, mnax: number, total: number, pre: string): void; + } + + interface FunctionInitComplete { + (settings: SettingsLegacy, json: Object): void; + } + + interface FunctionPreDrawCallback { + (settings: SettingsLegacy): void; + } + + interface FunctionRowCallback { + (row: Node, data: any[]| Object): void; + } + + interface FunctionStateLoadCallback { + (settings: SettingsLegacy): void; + } + + interface FunctionStateLoaded { + (settings: SettingsLegacy, data: Object): void; + } + + interface FunctionStateLoadParams { + (settings: SettingsLegacy, data: Object): void; + } + + interface FunctionStateSaveCallback { + (settings: SettingsLegacy, data: Object): void; + } + + interface FunctionStateSaveParams { + (settings: SettingsLegacy, data: Object): void; + } + + //#endregion "callback-functions" + + //#region "language-settings" + + interface LanguageSettings { + emptyTable: string; + info: string; + infoEmpty: string; + infoFiltered: string; + infoPostFix: string; + thousands: string; + lengthMenu: string; + loadingRecords: string; + processing: string; + search: string; + zeroRecords: string; + paginate: LanguagePaginateSettings; + aria: LanguageAriaSettings; + } + + interface LanguagePaginateSettings { + first: string; + last: string; + next: string; + previous: string; + } + + interface LanguageAriaSettings { + sortAscending: string; + sortDescending: string; + } + + //#endregion "language-settings" + + //#endregion "Settings" + + //#region "SettingsLegacy" + + interface ArrayStringNode { + [index: string]: Node; + } + + export interface SettingsLegacy { + ajax: any; + oApi: any; + oFeatures: FeaturesLegacy; + oScroll: ScrollingLegacy; + oLanguage: LanguageLegacy; // | { fnInfoCallback: FunctionInfoCallback; }; + oBrowser: { bScrollOversize: boolean; }; + aanFeatures: ArrayStringNode[][]; + aoData: RowLegacy[]; + aiDisplay: number[]; + aiDisplayMaster: number[]; + aoColumns: ColumnLegacy[]; + aoHeader: any[]; + aoFooter: any[]; + asDataSearch: string[]; + oPreviousSearch: any; + aoPreSearchCols: any[]; + aaSorting: any[][]; + aaSortingFixed: any[][]; + asStripeClasses: string[]; + asDestroyStripes: string[]; + sDestroyWidth: number; + aoRowCallback: FunctionRowCallback[]; + aoHeaderCallback: FunctionHeaderCallback[]; + aoFooterCallback: FunctionFooterCallback[]; + aoDrawCallback: FunctionDrawCallback[]; + aoRowCreatedCallback: FunctionCreateRow[]; + aoPreDrawCallback: FunctionPreDrawCallback[]; + aoInitComplete: FunctionInitComplete[]; + aoStateSaveParams: FunctionStateSaveParams[]; + aoStateLoadParams: FunctionStateLoadParams[]; + aoStateLoaded: FunctionStateLoaded[]; + sTableId: string; + nTable: Node; + nTHead: Node; + nTFoot: Node; + nTBody: Node; + nTableWrapper: Node; + bDeferLoading: boolean; + bInitialized: boolean; + aoOpenRows: any[]; + sDom: string; + sPaginationType: string; + iCookieDuration: number; + sCookiePrefix: string; + fnCookieCallback: CookieCallbackLegacy; + aoStateSave: FunctionStateSaveCallback[]; + aoStateLoad: FunctionStateLoadCallback[]; + oLoadedState: any; + sAjaxSource: string; + sAjaxDataProp: string; + bAjaxDataGet: boolean; + jqXHR: any; + fnServerData: any; + aoServerParams: any[]; + sServerMethod: string; + fnFormatNumber: FunctionFormatNumber; + aLengthMenu: any[]; + iDraw: number; + bDrawing: boolean; + iDrawError: number; + _iDisplayLength: number; + _iDisplayStart: number; + _iDisplayEnd: number; + _iRecordsTotal: number; + _iRecordsDisplay: number; + bJUI: boolean; + oClasses: any; + bFiltered: boolean; + bSorted: boolean; + bSortCellsTop: boolean; + oInit: any; + aoDestroyCallback: any[]; + fnRecordsTotal: () => number; + fnRecordsDisplay: () => number; + fnDisplayEnd: () => number; + oInstance: any; + sInstance: string; + iTabIndex: number; + nScrollHead: Node; + nScrollFoot: Node; + } + + export interface FeaturesLegacy { + bAutoWidth: boolean; + bDeferRender: boolean; + bFilter: boolean; + bInfo: boolean; + bLengthChange: boolean; + bPaginate: boolean; + bProcessing: boolean; + bServerSide: boolean; + bSort: boolean; + bSortClasses: boolean; + bStateSave: boolean; + } + + export interface ScrollingLegacy { + bAutoCss: boolean; + bCollapse: boolean; + bInfinite: boolean; + iBarWidth: number; + iLoadGap: number; + sX: string; + sY: string; + } + + export interface RowLegacy { + nTr: Node; + _aData: any; + _aSortData: any[]; + _anHidden: Node[]; + _sRowStripe: string; + } + + export interface ColumnLegacy { + aDataSort: any; + asSorting: string[]; + bSearchable: boolean; + bSortable: boolean; + bVisible: boolean; + _bAutoType: boolean; + fnCreatedCell: FunctionColumnCreatedCell; + fnGetData: (data: any, specific: string) => any; + fnSetData: (data: any, value: any) => void; + mData: any; + mRender: any; + nTh: Node; + nIf: Node; + sClass: string; + sContentPadding: string; + sDefaultContent: string; + sName: string; + sSortDataType: string; + sSortingClass: string; + sSortingClassJUI: string; + sTitle: string; + sType: string; + sWidth: string; + sWidthOrig: string; + } + + export interface CookieCallbackLegacy { + (name: string, data: any, expires: string, path: string, cookie: string): void; + } + + export interface LanguageLegacy { + oAria?: LanguageAriaLegacy; + oPaginate?: LanguagePaginateLegacy; + sEmptyTable?: string; + sInfo?: string; + sInfoEmpty?: string; + sInfoFiltered?: string; + sInfoPostFix?: string; + sInfoThousands?: string; + sLengthMenu?: string; + sLoadingRecords?: string; + sProcessing?: string; + sSearch?: string; + sUrl?: string; + sZeroRecords?: string; + } + + export interface LanguageAriaLegacy { + sSortAscending?: string; + sSortDescending?: string; + } + + export interface LanguagePaginateLegacy { + sFirst?: string; + sLast?: string; + sNext?: string; + sPrevious?: string; + } + //#endregion "SettingsLegacy" + } \ No newline at end of file From cc4234e4c707f3aeaca5c2554f5843d3431de628 Mon Sep 17 00:00:00 2001 From: Kiarash Ghiaseddin Date: Wed, 25 Mar 2015 17:57:32 +0100 Subject: [PATCH 5/7] Update header --- jquery.dataTables/jquery.dataTables.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index afeb01f0f..f57690b67 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -1,6 +1,6 @@ -// Type definitions for JQuery DataTables 1.10.5 +// Type definitions for JQuery DataTables 1.10.5 // Project: http://www.datatables.net -// Definitions by: Kiarash Ghiaseddin +// Definitions by: Kiarash Ghiaseddin , Omid Rad , Armin Sander // Definitions: https://github.com/borisyankov/DefinitelyTyped // missing: From dac611a93ddc7bf24f0895d2bc46e25fcaabf521 Mon Sep 17 00:00:00 2001 From: Kiarash Ghiaseddin Date: Wed, 25 Mar 2015 19:31:16 +0100 Subject: [PATCH 6/7] Add missing reference path to jquery.d.td --- jquery.dataTables/jquery.dataTables.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index f57690b67..cbcb1c025 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -8,6 +8,8 @@ // - Plugin and extension definitions are not typed. // - Some return types are not fully wokring +/// + interface JQuery { DataTable(param?: DataTables.Settings): DataTables.DataTable; } From 72cfe4041287b3b2014ba3df7a68f0958995f424 Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 7 Apr 2015 23:18:27 +0900 Subject: [PATCH 7/7] create old jquery.dataTables definition backup --- .../jquery.dataTables-1.9.4.d.ts | 479 ++++++++++++++++++ 1 file changed, 479 insertions(+) create mode 100755 jquery.dataTables/jquery.dataTables-1.9.4.d.ts diff --git a/jquery.dataTables/jquery.dataTables-1.9.4.d.ts b/jquery.dataTables/jquery.dataTables-1.9.4.d.ts new file mode 100755 index 000000000..9884b78e2 --- /dev/null +++ b/jquery.dataTables/jquery.dataTables-1.9.4.d.ts @@ -0,0 +1,479 @@ +// Type definitions for JQuery DataTables 1.9.4 +// Project: http://www.datatables.net +// Definitions by: Armin Sander +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// missing: +// - Static methods that are defined in JQueryStatic.fn are not typed. +// - Plugin and extension definitions are not typed. + +interface JQuery +{ + dataTable(param? :DataTables.Options) : DataTables.DataTable; +} + +declare module DataTables +{ + export interface DataTable + { + /// Perform a jQuery selector action on the table's TR elements (from the tbody) and return the resulting jQuery object. + $(selector:string, opts?:RowParams): JQuery; + $(selector:Node[], opts?:RowParams): JQuery; + $(selector:JQuery, opts?:RowParams): JQuery; + + /// Almost identical to $ in operation, but in this case returns the data for the matched rows. + _(selector:string, opts?:RowParams): any[]; + _(selector:Node[], opts?:RowParams): any[]; + _(selector:JQuery, opts?:RowParams): any[]; + + /// Add a single new row or multiple rows of data to the table. + fnAddData(data:any, redraw?:boolean) : number[]; + + /// This function will make DataTables recalculate the column sizes. + fnAdjustColumnSizing(redraw? : boolean) : void; + + /// Quickly and simply clear a table + fnClearTable(redraw? : boolean) : void; + + /// The exact opposite of 'opening' a row, this function will close any rows which are currently 'open'. + fnClose(node: Node) : number; + + /// Remove a row for the table + fnDeleteRow(index: number, callback?: () => void, redraw?: boolean) : any[]; + fnDeleteRow(tr: Node, callback?: () => void, redraw?: boolean) : any[]; + + /// Restore the table to it's original state in the DOM by removing all of DataTables enhancements, + /// alterations to the DOM structure of the table and event listeners. + fnDestroy(remove?: boolean) : void; + + /// Redraw the table + fnDraw(complete? : boolean) : void; + + /// Filter the input based on data + fnFilter(input: string, column? : number, regex?: boolean, smart? : boolean, showGlobal?: boolean, caseInsensitive? : boolean) : void; + + /// Get the data for the whole table, an individual row or an individual cell based on the provided parameters. + fnGetData(row?: Node, col? : number) : any; + fnGetData(row?: number, col? : number) : any; + + /// Get an array of the TR nodes that are used in the table's body. + fnGetNodes(row? : number) : any; // Node[] | Node + + /// Get the array indexes of a particular cell from it's DOM element and column index including hidden columns + fnGetPosition(node: Node) : any; // number | number[] + + /// Check to see if a row is 'open' or not. + fnIsOpen(tr: Node) : boolean; + + /// This function will place a new row directly after a row which is currently on display on the page, + /// with the HTML contents that is passed into the function. + fnOpen(node: Node, html: string, clazz: string) : Node; + fnOpen(node: Node, html: Node, clazz: string) : Node; + fnOpen(node: Node, html: JQuery, clazz: string) : Node; + + /// Change the pagination - provides the internal logic for pagination in a simple API function. + fnPageChange(action: string, redraw?: boolean) : void; + fnPageChange(page: number, redraw?: boolean) : void; + + /// Show a particular column + fnSetColumnVis(column: number, show: boolean, redraw?: boolean) : void; + + /// Get the settings for a particular table for external manipulation + fnSettings() : Settings; + + /// Sort the table by a particular column + fnSort(col: number) : void; + fnSort(col: any[][]) : void; + + /// Attach a sort listener to an element for a given column + fnSortListener(node: Node, column: number, callback? : () => void): void; + + /// Update a table cell or row - this method will accept either a single value to update the cell with, + /// an array of values with one element for each column or an object in the same format as the original data source. + fnUpdate(data: any, row: Node, column?:number, redraw?: boolean, action? : boolean) : number; + fnUpdate(data: any, dataIndex: number, column?:number, redraw?: boolean, action? : boolean) : number; + + /// Provide a common method for plug-ins to check the version of DataTables being used, + /// in order to ensure compatibility. + fnVersionCheck(version: string) : boolean; + } + + export interface Static + { + /// Provide a common method for plug-ins to check the version of DataTables being used, + /// in order to ensure compatibility. + fnVersionCheck(version: string) : boolean; + + /// Check if a TABLE node is a DataTable table already or not. + fnIsDataTable(table: Node) : boolean; + + /// Get all DataTable tables that have been initialised. + fnTables(visible? : boolean) : Node[]; + } + + export interface RowParams + { + /// Select TR elements that meet the current filter criterion ("applied") or all TR elements (i.e. no filter). + filter?: string; + + /// Order of the TR elements in the processed array. + /// Can be either 'current', whereby the current sorting of the table is used, or + /// 'original' whereby the original order the data was read into the table is used. + order?: string; + + /// Limit the selection to the currently displayed page + /// ("current") or not ("all"). If 'current' is given, then order is assumed to be + /// 'current' and filter is 'applied', regardless of what they might be given as. + page?: string; + } + + export interface Options + { + aaData?: any[]; + aaSorting?: any[]; + aaSortingFixed?: any[]; + ajax?: any; + aLengthMenu?: any[]; + aoColumns?: ColumnOptions[]; + aoColumnDefs?: ColumnDef[]; + aoSearchCols?: any[]; + asStripClasses?: string[]; + bAutoWidth?: boolean; + bDeferRender?: boolean; + bDestroy?: boolean; + bFilter?: boolean; + bInfo?: boolean; + bJQueryUI?: boolean; + bLengthChange?: boolean; + bPaginate?: boolean; + bProcessing?: boolean; + bRetrieve?: boolean; + bScrollAutoCss?: boolean; + bScrollCollapse?: boolean; + bScrollInfinite?: boolean; + bServerSide?: boolean; + bSort?: boolean; + bSortCellsTop?: boolean; + bSortClasses?: boolean; + bStateSave?: boolean; + fnCookieCallback?: CookieCallback; + fnCreatedRow?: RowCreatedCallback; + fnDrawCallback?: DrawCallback; + fnFooterCallback?: FooterCallback; + fnFormatNumber?: FormatNumber; + fnHeaderCallback?: HeaderCallback; + fnInfoCallback?: InfoCallback; + fnInitComplete?: InitComplete; + fnPreDrawCallback?: PreDrawCallback; + fnRowCallback?: RowCallback; + + fnStateLoadCallback?: StateLoadCallback; + fnStateLoadParams?: StateLoadParams; + fnStateLoaded?: StateLoaded; + fnStateSaveCallback?: StateSaveCallback; + fnStateSaveParams?: StateSaveParams; + iCookieDuration?: number; + iDeferLoading?: any; + iDisplayLength?: number; + iDisplayStart?: number; + iScrollLoadGap?: number; + iTabIndex?: number; + oLanguage?: LanguageOptions; + oSearch?: any; + sAjaxDataProp?: string; + sAjaxSource?: string; + sCookiePrefix?: string; + sDom?: string; + sPaginationType?: string; + sScrollX?: string; + sScrollXInner?: string; + sScrollY?: string; + sServerMethod? : string; + } + + export interface LanguageOptions + { + oAria? : AriaOptions; + oPaginate? : PaginateOptions; + sEmptyTable?: string; + sInfo?: string; + sInfoEmpty?: string; + sInfoFiltered?: string; + sInfoPostFix?: string; + sInfoThousands?: string; + sLengthMenu?: string; + sLoadingRecords?: string; + sProcessing?: string; + sSearch?: string; + sUrl?: string; + sZeroRecords?: string; + } + + export interface AriaOptions + { + sSortAscending?: string; + sSortDescending?: string; + } + + export interface PaginateOptions + { + sFirst?: string; + sLast?: string; + sNext?: string; + sPrevious?: string; + } + + export interface ColumnOptions + { + aDataSort?: number[]; + asSorting?: string[]; + bSearchable? : boolean; + bSortable? : boolean; + bVisible? : boolean; + _bAutoType? : boolean; + fnCreatedCell?: CreatedCell; + iDataSort?: number; + mData?: any; + mRender?: any; + sCellType?: string; + sClass?: string; + sContentPadding?: string; + sDefaultContent?: string; + sName?: string; + sSortDataType?: string; + sSortingClass?: string; + sTitle?: string; + sType?: string; + sWidth?: string; + } + + export interface ColumnDef extends ColumnOptions + { + aTargets: any[]; + } + + export interface Settings + { + oFeatures : Features; + oScroll: ScrollingSettings; + oLanguage : { fnInfoCallback : InfoCallback; }; + oBrowser : { bScrollOversize : boolean; }; + aanFeatures: Node[][]; + aoData: Row[]; + aiDisplay: number[]; + aiDisplayMaster: number[]; + aoColumns: Column[]; + aoHeader: any[]; + aoFooter: any[]; + asDataSearch: string[]; + oPreviousSearch: any; + aoPreSearchCols: any[]; + aaSorting: any[][]; + aaSortingFixed: any[][]; + asStripeClasses: string[]; + asDestroyStripes: string[]; + sDestroyWidth: number; + aoRowCallback: RowCallback[]; + aoHeaderCallback: HeaderCallback[]; + aoFooterCallback: FooterCallback[]; + aoDrawCallback: DrawCallback[]; + aoRowCreatedCallback: RowCreatedCallback[]; + aoPreDrawCallback: PreDrawCallback[]; + aoInitComplete: InitComplete[]; + aoStateSaveParams: StateSaveParams[]; + aoStateLoadParams: StateLoadParams[]; + aoStateLoaded: StateLoaded[]; + sTableId: string; + nTable: Node; + nTHead: Node; + nTFoot: Node; + nTBody: Node; + nTableWrapper: Node; + bDeferLoading: boolean; + bInitialized: boolean; + aoOpenRows: any[]; + sDom: string; + sPaginationType: string; + iCookieDuration: number; + sCookiePrefix: string; + fnCookieCallback: CookieCallback; + aoStateSave: StateSaveCallback[]; + aoStateLoad: StateLoadCallback[]; + oLoadedState: any; + sAjaxSource: string; + sAjaxDataProp: string; + bAjaxDataGet: boolean; + jqXHR: any; + fnServerData: any; + aoServerParams: any[]; + sServerMethod: string; + fnFormatNumber: FormatNumber; + aLengthMenu: any[]; + iDraw: number; + bDrawing: boolean; + iDrawError: number; + _iDisplayLength: number; + _iDisplayStart: number; + _iDisplayEnd: number; + _iRecordsTotal: number; + _iRecordsDisplay: number; + bJUI: boolean; + oClasses: any; + bFiltered: boolean; + bSorted: boolean; + bSortCellsTop: boolean; + oInit: any; + aoDestroyCallback: any[]; + fnRecordsTotal: () => number; + fnRecordsDisplay: () => number; + fnDisplayEnd: () => number; + oInstance : any; + sInstance: string; + iTabIndex: number; + nScrollHead: Node; + nScrollFoot: Node; + } + + export interface Features + { + bAutoWidth: boolean; + bDeferRender: boolean; + bFilter: boolean; + bInfo: boolean; + bLengthChange: boolean; + bPaginate: boolean; + bProcessing: boolean; + bServerSide: boolean; + bSort: boolean; + bSortClasses: boolean; + bStateSave: boolean; + } + + export interface ScrollingSettings + { + bAutoCss : boolean; + bCollapse: boolean; + bInfinite: boolean; + iBarWidth: number; + iLoadGap: number; + sX: string; + sY: string; + } + + export interface Row + { + nTr: Node; + _aData: any; + _aSortData: any[]; + _anHidden: Node[]; + _sRowStripe: string; + } + + export interface Column + { + aDataSort: any; + asSorting: string[]; + bSearchable : boolean; + bSortable : boolean; + bVisible : boolean; + _bAutoType : boolean; + fnCreatedCell: CreatedCell; + fnGetData: (data: any, specific: string) => any; + fnSetData: (data: any, value: any) => void; + mData: any; + mRender: any; + nTh: Node; + nIf: Node; + sClass: string; + sContentPadding: string; + sDefaultContent: string; + sName: string; + sSortDataType: string; + sSortingClass: string; + sSortingClassJUI: string; + sTitle: string; + sType: string; + sWidth: string; + sWidthOrig: string; + } + + export interface CookieCallback + { + (name: string, data: any, expires: string, path: string, cookie: string) : void; + } + + export interface RowCreatedCallback + { + (row: Node, data: any[], dataIndex: number) : void; + } + + export interface DrawCallback + { + (settings: Settings) : void; + } + + export interface FooterCallback + { + (foot: Element, data: any[], start:number, end:number, display: number[]) : void; + } + + export interface FormatNumber + { + (toFormat: number) : string; + } + + export interface HeaderCallback + { + (head: Element, data: any[], start:number, end:number, display: number[]) : void; + } + + export interface InfoCallback + { + (settings: Settings, start: number, end: number, max:number, total: number, pre: string) : string; + } + + export interface InitComplete + { + (settings: Settings, json: any) : void; + } + + export interface PreDrawCallback + { + (settings: Settings) : boolean; + } + + export interface RowCallback + { + (row : Settings, data: any[], displayIndex: number, displayIndexFull: number) : void; + } + + export interface StateLoadCallback + { + (settings: Settings) : any; + } + + export interface StateLoadParams + { + (settings: Settings, data: any) : void; + } + + export interface StateLoaded + { + (settings: Settings, data: any) : void; + } + + export interface StateSaveCallback + { + (settings: any, data:any) : void; + } + + export interface StateSaveParams + { + (settings: any, data:any) : void; + } + + export interface CreatedCell + { + (nTd: Node, cellData: any, rowData: any, row: number, col: number) : void; + } +}