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