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

Add an option to make the dropdown-menu unique on a page with multiple dataTables #15

Open
klingo opened this issue Sep 1, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@klingo
Copy link

klingo commented Sep 1, 2023

When we have multiple DataTables on the same page; each dataTable can have it's own dropdown-menu open at the same time.
We woud like to avoid this and make sure there is only ever one dropdown-menu open across all dataTables.

A workaround I have found for this is to "misuse" the headerRenderer function to count the number of div.dropdown-menu elements present on the page. If there is >1, then I compare the dataTable-Id with the Id of the dropdown (since it starts with that) and then remove the not-matching div.dropdown-menu.

headerRenderer: () => {
    if ($('div.dropdown-menu').length > 1) {
        $('div.dropdown-menu').each((k, v) => {
            if (!v.id.startsWith(tableId)) $(v).remove();
        });
    }
    return 'header label';
}

Maybe this behaviour could be added as a configuration option?

@torrobinson torrobinson self-assigned this Sep 24, 2023
@torrobinson torrobinson added the enhancement New feature or request label Sep 24, 2023
@torrobinson
Copy link
Owner

Good idea! I've never tested with more than 1 on a page, but this certainly sounds doable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants