Disable editing for specific columns in tabulator?

Hi,

I would like to disable editing for a specific column in a tabulator but not for the whole tabulator. In the panel docs it talks about being able to set custom editors (Tabulator β€” Panel 0.12.6 documentation). For example I would like to be able to edit Col 2 and Col 3 but not Col1. I tried setting an editor and giving it editable: False (see code) but this does not work, the cells in the column are still editable. Is there some way to accomplish this?

import pandas as pd
import panel as pn

df = pd.DataFrame({
    'Col 1': [1, 2, 3],
    'Col 2': [True, False, True],
    'Col 3': ['A', 'B', 'C'],
})

editors = {
    'Col 1': {'type': 'number', 'editable': False},
}
tabulator = pn.widgets.Tabulator(df, editors=editors)
tabulator.show()

image

Hi @cdives,

I think the below gives you desired functionality just needed to change a couple of things in the edittors line, hope it helps

import pandas as pd
import panel as pn

df = pd.DataFrame({
    'Col 1': [1, 2, 3],
    'Col 2': [True, False, True],
    'Col 3': ['A', 'B', 'C'],
})

editors = {
    'Col 1': {'type': 'editable', 'value': False}, #altered this line, to selecting the type of tabulator editor required and value to pass to it
}
tabulator = pn.widgets.Tabulator(df, editors=editors)
tabulator.show()
4 Likes

That works great. Thanks!

1 Like

Hi all,

Couple of questions:
1.-Where did you find the information about setting up de editors?
2.-What about disabling some rows?

Thanks,

Hi @ransona,

I found the information here https://panel.holoviz.org/reference/widgets/Tabulator.html and here https://tabulator.info/docs/4.9/edit#edit

For point 2 sounds possible but I don’t know myself without reading into it more

Thanks, Carl

1 Like

Thanks for your prompt answer. I will dive in to see how to disable rows, instead of columns. Thanks for the information.
Merry Christmas

1 Like