1 <?xml version="1.0" encoding="UTF-8" ?>
2 <dt-api library="FixedColumns">
3 <name>fixedColumns().cellIndex()</name>
4 <summary>Get the cell index of a cell in a fixed column</summary>
8 <signature>fixedColumns().cellIndex( row )</signature>
9 <parameter type="jQuery|node" name="row">
10 The cell (`-tag td` or `-tag th`) to get the cell index of. This can be either a cell in the fixed columns or in the host DataTable.
12 <returns type="object">
13 The cell index for the given cell.
16 Get the cell index (`dt-api cell().index()`) for a `-tag td`/`-tag th` element, regardless of if the cell is contained in a fixed column, or in the scrolling table.
21 <version>3.2.1</version>
23 As of DataTables 1.10.11 and FixedColumns 3.2.1 this method is no longer required to obtain a cell index from a node as the `dt-api cell()` method will accept the `-tag td` elements in the fixed column as selector arguments.
25 <example title="Get the cell index for any cell clicked upon in a table (from the fixed column, or the main table)"><![CDATA[
27 var table = $('myTable').DataTable();
29 $(table.table().container()).on( 'click', 'td', function () {
30 var cell = table.cell( this );
32 console.log( cell.index() );
40 When working with FixedColumns, there is additional complexity in the DataTable as the fixed columns are not technically part of the host DataTables - they just look like it! They are in fact HTML `-tag table` elements themselves, with specific styling to visually integrate them with the host table.
42 Since the fixed columns are the ones that the end user sees, they are also the ones that the user will interact with - for example clicking on a cell in the fixed column will give the fixed column cell and _not_ the cell in the DataTable!
44 This method is provided to be able to convert from a cell in the fixed columns into a DataTables cell, by returning the cell data index (this is _not_ the visible index, but rather an index internal to DataTables!). That index can then be used with the `dt-api cell()` method to obtain a reference to the main DataTable cell.
47 <example title="Get the cell index for any cell clicked upon in a table"><![CDATA[
49 $(document).on( 'click', 'td', function () {
51 $('#example').DataTable().fixedColumns().cellIndex()