Hi all,
I’m using panel.widget.Tabulator for the first time. It’s super useful widget and very versatile.
I wish there was more documents and examples for it.
I need to add a trash can column to the table and allow user to delete a row when they click on the trash can for that row.
Getting idea from here, I wrote following code:
I found following in the documents, but I still cannot get it working.
| on_click(self, callback: ‘Callable[[CellClickEvent], None]’, column: ‘Optional[str]’ = None)
| Register a callback to be executed when any cell is clicked.
| The callback is given a CellClickEvent declaring the column
| and row of the cell that was clicked.
|
Arguments
callback: (callable)
The callback to run on edit events.
column: (str)
Optional argument restricting the callback to a specific
Thanks Mana. I have been following the Tabulator documentation, will look more into that.
Regarding point 3, yes, that is true. Just with the above solution, it is not possible to edit the table as the whole row is selected for deletion. If there is a workaround, please share, else I will figure it out. Thanks in advance!
Ah got it. I had to set “disabled=False” in tbl = pn.widgets.Tabulator() call. So now both editing and removing a row works!
I will figure out how to add a row dynamically to an existing table (just like you did to remove a row).
Very nice solution. There’s one little limitation that can easily be fixed. If you click directly on the trash icon (without highlighting the row) nothing happens. This can be fixed by changing the function slightly as follows: