column().dataSrc()
Get the data source property for the selected column.
Description
DataTables has the ability to read data from a variety of complex data sources through use of the columns.data
option. This method provides the ability to retrieve that setting after initialisation based on a column selector (see column-selector
).
The value of columns.data
that was set during initialisation (including the default of a column index integer) will be returned by this method, including functions (unevaluated). It is important to note that how columns.render
is set has no effect on the return value of this method, which is used only for retrieving the value of columns.data
.
It is not possible at this time to use this method as a setter - the data source for a column cannot be changed after initialisation.
Type
function column().dataSrc()
- Description:
Get the data source property for the selected column
- Returns:
Data source parameter as configured by
columns.data
Example
Get the data source for a column that was clicked on:
var table = new DataTable('#myTable');
$('#example').on('click', 'tbody td', function () {
var idx = table.cell(this).index().column;
alert('Data source: ' + table.column(idx).dataSrc());
});
Related
The following options are directly related and may also be useful in your application development.