Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Input or select field #4

Open
musicman3 opened this issue Feb 2, 2021 · 4 comments
Open

Input or select field #4

musicman3 opened this issue Feb 2, 2021 · 4 comments

Comments

@musicman3
Copy link

musicman3 commented Feb 2, 2021

Hello. How can I make an option or an input field in this menu? I need to insert these options into the context menu sections. It is also not clear how to bind a menu to a table row by id

@heapoverride
Copy link
Owner

heapoverride commented Feb 3, 2021

Hello. How can I make an option or an input field in this menu?

You can't at the moment. I will consider this and maybe it will be possible to choose a type of menu item to render (text, inputbox etc...)

"It is also not clear how to bind a menu to a table row by id"

Do you want each table row to have different context menu?

image

const dataTable = document.getElementById('data-table');
let contextMenu = null;

dataTable.addEventListener('contextmenu', e => {
    e.preventDefault();

    if (contextMenu != null) {
        contextMenu.hide();
        contextMenu.uninstall();
    }

    contextMenu = new ContextMenu(document.body, [{
        text: 'Remove row',
        onclick: ee => {
            if (e.target.parentElement.tagName == 'TR') {
                e.target.parentElement.parentElement.removeChild(e.target.parentElement);
            }
        }
    }, ]);

    contextMenu.install();
});

@Risingson
Copy link

or maybe just passing html for a menu entry?

@musicman3
Copy link
Author

musicman3 commented Feb 4, 2021

Thanks. Need to pass html to menu cell

@heapoverride
Copy link
Owner

or maybe just passing html for a menu entry?

Not sufficient if you want the data to persist but it's great to have suggestions so they can be tried.
ContextMenu is rebuilt every time it is requested.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants