Class: FixedColumns - documentation

# Class: FixedColumns

FixedColumns v3.0.0 documentation

new FixedColumns(dt, init)

  When making use of DataTables' x-axis scrolling feature, you may wish to fix the left most column in place. This plug-in for DataTables provides exactly this option (note for non-scrolling tables, please use the FixedHeader plug-in, which can fix headers, footers and columns). Key features include:

  - Freezes the left or right most columns to the side of the table
  - Option to freeze two or more columns
  - Full integration with DataTables' scrolling options
  - Speed - FixedColumns is fast in its operation

  ### Constructor

  ##### Parameters:

  | Name | Type | Attributes | Default | Description
  --- | --- | --- | --- | --- | ---
  1 | dt | object |  |  | DataTables instance. With DataTables 1.10 this can also be a jQuery collection, a jQuery selector, DataTables API instance or settings object.
  2 | init | object | Optional | {} | Configuration object for FixedColumns. Options are defined by FixedColumns.defaults

  ##### Example:

           var table = $('#example').dataTable( {
             "scrollX": "100%"
           } );
           new $.fn.dataTable.fixedColumns( table );

### Requires

- jQuery 1.7+
- DataTables 1.8.0+

## Summary

### Namespaces

defaults

  FixedColumns default settings for initialisation

### Properties - static

<static> version :String

  FixedColumns version

### Methods - instance

fnGetPosition(node) → {int}

  Get data index information about a row or cell in the table body. This function is functionally identical to fnGetPosition in DataTables, taking the same parameter (TH, TD or TR node) and returning exactly the the same information (data index information). THe difference between the two is that this method takes into account the fixed columns in the table, so you can pass in nodes from the master table, or the cloned tables and get the index position for the data in the main table.

fnRecalculateHeight(nTr) → {void}

  Mark a row such that it's height should be recalculated when using 'semiauto' row height matching. This function will have no effect when 'none' or 'auto' row height matching is used.

fnRedrawLayout() → {void}

  Recalculate the resizes of the 3x3 grid that FixedColumns uses for display of the table. This is useful if you update the width of the table container. Note that FixedColumns will perform this function automatically when the window.resize event is fired.

fnSetRowHeight(nTarget, iHeight) → {void}

  Set the height of a given row - provides cross browser compatibility

fnUpdate() → {void}

  Update the fixed columns - including headers and footers. Note that FixedColumns will automatically update the display whenever the host DataTable redraws.

## Details

### Properties - static

<static> version :String

  FixedColumns version

### Methods - instance

fnGetPosition(node) → {int}

  Get data index information about a row or cell in the table body. This function is functionally identical to fnGetPosition in DataTables, taking the same parameter (TH, TD or TR node) and returning exactly the the same information (data index information). THe difference between the two is that this method takes into account the fixed columns in the table, so you can pass in nodes from the master table, or the cloned tables and get the index position for the data in the main table.

  ##### Parameters:

  | Name | Type | Attributes | Default | Description
  --- | --- | --- | --- | --- | ---
  1 | node | node |  |  | TR, TH or TD element to get the information about

  ##### Returns:

  If nNode is given as a TR, then a single index is returned, or if given as a cell, an array of [row index, column index (visible), column index (all)] is given.

fnRecalculateHeight(nTr) → {void}

  Mark a row such that it's height should be recalculated when using 'semiauto' row height matching. This function will have no effect when 'none' or 'auto' row height matching is used.

  ##### Parameters:

  | Name | Type | Attributes | Default | Description
  --- | --- | --- | --- | --- | ---
  1 | nTr | Node |  |  | TR element that should have it's height recalculated

  ##### Example:

           var table = $('#example').dataTable( {
               "scrollX": "100%"
           } );
           var fc = new $.fn.dataTable.fixedColumns( table );

           // manipulate the table - mark the row as needing an update then update the table
           // this allows the redraw performed by DataTables fnUpdate to recalculate the row
           // height
           fc.fnRecalculateHeight();
           table.fnUpdate( $('#example tbody tr:eq(0)')[0], ["insert date", 1, 2, 3 ... ]);

fnRedrawLayout() → {void}

  Recalculate the resizes of the 3x3 grid that FixedColumns uses for display of the table. This is useful if you update the width of the table container. Note that FixedColumns will perform this function automatically when the window.resize event is fired.

  ##### Example:

           var table = $('#example').dataTable( {
               "scrollX": "100%"
           } );
           var fc = new $.fn.dataTable.fixedColumns( table );

           // Resize the table container and then have FixedColumns adjust its layout....
           $('#content').width( 1200 );
           fc.fnRedrawLayout();

fnSetRowHeight(nTarget, iHeight) → {void}

  Set the height of a given row - provides cross browser compatibility

  ##### Parameters:

  | Name | Type | Attributes | Default | Description
  --- | --- | --- | --- | --- | ---
  1 | nTarget | Node |  |  | TR element that should have it's height recalculated
  2 | iHeight | int |  |  | Height in pixels to set

  ##### Example:

           var table = $('#example').dataTable( {
               "scrollX": "100%"
           } );
           var fc = new $.fn.dataTable.fixedColumns( table );

           // You may want to do this after manipulating a row in the fixed column
           fc.fnSetRowHeight( $('#example tbody tr:eq(0)')[0], 50 );

fnUpdate() → {void}

  Update the fixed columns - including headers and footers. Note that FixedColumns will automatically update the display whenever the host DataTable redraws.

  ##### Example:

           var table = $('#example').dataTable( {
               "scrollX": "100%"
           } );
           var fc = new $.fn.dataTable.fixedColumns( table );

           // at some later point when the table has been manipulated....
           fc.fnUpdate();