{hero}

searchPanes.threshold

Since: SearchPanes SearchPanes 1.0.0

Set the minimum number of unique values needed in the columns to display that pane.
Please note - this property requires the SearchPanes extension for DataTables.

Description

As standard, columns must have a uniqueness ratio of 0.6. This is the ratio of different values throughout the column to the number of total values. If all values are unique, this will be 1; as the value drops towards 0, this means values are more often repeated. The benefit of dividing by the total values means that when arrays are present then the same logic applies. For example you may have a table with 2 rows, and each row contains 4 unique options in the column with arrays present. If you were to just divide by the row count then you would have a threshold of 4, outwith the value we are looking for. Dividing instead by the number of total options brings the value back to 1, which is within the range.

By setting the searchPanes.threshold option to a different decimal value, the uniqueness ratio must be less than this value to display the pane.

This is useful as it determines at what point a pane for the specified column should be shown. If all panes for tables with lots of columns were shown, the searching may become confusing. This adjustment allows searchPanes to internally make the decisions to display a simpler, less cluttered user interface.

The threshold of the uniqueness ratio can also be set for individual columns by making use of the columns.searchPanes.threshold option.

If you want to force specific panes to always be present, or to always be hidden, use the columns.searchPanes.show option.

Type

Decimal

Description:

By setting the searchPanes.threshold option to a decimal value between 0 and 1 it is possible to alter when the panes are displayed.

Default

  • Value: 0.6

The default value for the searchPanes.threshold parameter is 0.6. This default value means that columns with a ratio of different values in the column to total rows is less than 0.6 then the pane will be shown. If the value is overwritten then if the ratio is less than that value then the pane will be shown.

Example

Change the threshold of the uniqueness ratio:

$(document).ready(function() {
    $('#example').DataTable({
        searchPanes: {
            threshold: 0.4
        },
        dom: 'Plfrtip'
    });
});

Related

The following options are directly related and may also be useful in your application development.