Column Control#

The columnControl option lets you add column specific controls.

The examples should give you a quick sense of how to use columnControl. You are invited to consult the datatables documentation for many more column control examples - see also Allan’s post in which the extension was introduced.

import itables

itables.init_notebook_mode()

df = itables.sample_dfs.get_countries()

Getting started#

The columnControl option can take as value the list of controls that should be added to the table columns.

itables.show(
    df,
    columnControl=["order", "colVisDropdown", "searchDropdown"],
    ordering={"indicators": False, "handler": False},
)
region country capital longitude latitude
code
AWLatin America & Caribbean ArubaOranjestad-70.01670012.516700
AFSouth AsiaAfghanistanKabul69.17610034.522800
AOSub-Saharan Africa AngolaLuanda13.242000-8.811550
ALEurope & Central AsiaAlbaniaTirane19.81720041.331700
ADEurope & Central AsiaAndorraAndorra la Vella1.52180042.507500
AEMiddle East & North AfricaUnited Arab EmiratesAbu Dhabi54.37050024.476400
ARLatin America & Caribbean ArgentinaBuenos Aires-58.417300-34.611800
AMEurope & Central AsiaArmeniaYerevan44.50900040.159600
ASEast Asia & PacificAmerican SamoaPago Pago-170.691000-14.284600
AGLatin America & Caribbean Antigua and BarbudaSaint John's-61.84560017.117500
(198 more rows not shown)

Tip

When an ordering option is provided through the columnControl option, you probably want to deactivate the default ordering icons - that’s the purpose of ordering={"indicators": False, "handler": False} used in the example above.

Controls and table footers#

The column controls can also be added to a table footer:

itables.show(
    df,
    columnControl=[
        {"target": 0, "content": ["order"]},
        {"target": "tfoot", "content": ["search"]},
    ],
    ordering={"indicators": False, "handler": False},
)
region country capital longitude latitude
code
AWLatin America & Caribbean ArubaOranjestad-70.01670012.516700
AFSouth AsiaAfghanistanKabul69.17610034.522800
AOSub-Saharan Africa AngolaLuanda13.242000-8.811550
ALEurope & Central AsiaAlbaniaTirane19.81720041.331700
ADEurope & Central AsiaAndorraAndorra la Vella1.52180042.507500
AEMiddle East & North AfricaUnited Arab EmiratesAbu Dhabi54.37050024.476400
ARLatin America & Caribbean ArgentinaBuenos Aires-58.417300-34.611800
AMEurope & Central AsiaArmeniaYerevan44.50900040.159600
ASEast Asia & PacificAmerican SamoaPago Pago-170.691000-14.284600
AGLatin America & Caribbean Antigua and BarbudaSaint John's-61.84560017.117500
(198 more rows not shown)

As usual, you can make this the default by either setting itables.options.columnControl in your notebook or application, or by adding this to your itables.toml configuration file:

[[columnControl]]
target = 0
content = ["order"]
[[columnControl]]
target = "tfoot"
content = ["search"]

[ordering]
indicators = false
handler = false