Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context Menu feature implementation for Panel Tabulator #5995

Open
tempNoobie opened this issue Dec 5, 2023 · 0 comments
Open

Context Menu feature implementation for Panel Tabulator #5995

tempNoobie opened this issue Dec 5, 2023 · 0 comments

Comments

@tempNoobie
Copy link

The main idea behind this feature is to provide a context menu for panel tabulator widget as in Tabulator.

Motivation

  • This feature will allow users to perform actions on specific rows or cells within the table which in turn enhances data manipulation capabilities.
  • Even though the same could be done using the selection feature, it has its own advantages and disadvantages, upon selection of a particular cell, the selection remains even after the required operation is completed.
  • A more efficient way is required to trigger custom functions based on the selected item.
  • A separate menu or interface is not required if this feature is implemented.

Requirement

  • The context menu should be triggered by a right-click on a particular cell.
  • A basic set of standard operations can be provided. (copy, edit, delete etc)
  • Context Menu options should be configurable.
  • User defined functions (custom actions) should be executed upon selection of option from the context menu

Currently followed approach

import pandas as pd
import panel as pn

raw_data = \
[
  {
    "value": 'A',
    "frequency": 3
  },
  {
    "value": 'B',
    "frequency": 2
  },
  {
    "value": 'C',
    "frequency": 1
  },
  {
    "value": 'D',
    "frequency": 1
  },
  {
    "value": 'E',
    "frequency": 1
  },
  {
    "value": 'F',
    "frequency": 2
  },
]

def contextMenu():
    print("Selected Option One from context menu...")

value_freq = pd.DataFrame(raw_data)
tabWid = pn.widgets.Tabulator(value_freq, configuration={
                                                            'rowContextMenu':[
                                                                {
                                                                    'label':'Option One',
                                                                    'action':contextMenu()
                                                        
                                                                },
                                                                {
                                                                    'separator':True
                                                                },
                                                            ]
                                                        })
pn.Row(tabWid).servable()

Issue with this approach

  • The above approach works and also the context menu is also triggered upon right click, the only problem is the custom function is not triggered.
  • The function is called only during the initialization phase.
  • The same was also posted in the panel community - Discussion

My first feature request hopefully it is well structured and necessary details are provided 🙂

@tempNoobie tempNoobie reopened this Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant