Datatables obscures Bootstrap4 dropdown menu

When using Bootstrap4 to create a button with a DropDown menu for each row in a DataTables grid, I encountered an issue. Upon clicking the button, the datatables footer cuts off my menu. I am using Angular5 and Bootstrap4.

Here is a screenshot of the problem:

https://i.sstatic.net/Ydztj.png

Below is the code snippet:

<table id="e-commerce-products-table" class="table dataTable">
                    <thead>
                        <tr>
                            <th>
                                <div class="table-header">
                                    <span class="column-title">ID</span>
                                </div>
                            </th>
                            <th>
                                <div class="table-header">
                                    <span class="column-title">Status</span>
                                </div>
                            </th>
                            <th>
                                <div class="table-header">
                                    <span class="column-title">Date Creation</span>
                                </div>
                            </th>
                            <th>
                                <div class="table-header">
                                    <span class="column-title">Client</span>
                                </div>
                            </th>
                            <th>
                                <div class="table-header">
                                    <span class="column-title">Actions</span>
                                </div>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr *ngFor='let c of dossiers'>
                            <td class="name">{{c.numero}}</td>
                            <td class="type d-none d-md-table-cell">{{c.status}}</td>
                            <td class="owner d-none d-sm-table-cell">{{c.dateCreation}}</td>
                            <td class="size d-none d-sm-table-cell">
                                <a class="icon-eye" data-toggle="modal" data-target="#gridSystemModal" (click)="affectationClient(c.client.idClient)"></a>
                            </td>
                            <td class="last-modified d-none d-lg-table-cell">
                                <div class="dropdown ">
                                    <button type="button" class="btn btn-icon" aria-label="btnGroup" data-toggle="dropdown">
                                        <i class="icon icon-dots-vertical"></i>
                                    </button>
                                    <div class="dropdown-menu dropdown-menu-right " id="myMenu" aria-labelledby="btnGroup">
                                        <button class="dropdown-item" data-toggle="modal" data-target="#modifierDossier" (click)="affectationDossier(c)">Modifier Dossier</button>
                                        <button class="dropdown-item" data-toggle="modal" data-target="#supprimerDosssier" (click)="affectationClient(c.client.idClient)">Supprimer Dossier</button>
                                        <a class="dropdown-item" href="dossiers/details?id={{c.id}}">Details Dossier</a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>

Answer №1

Instructions:

To ensure proper positioning of the dropdown menu, follow these steps:

Step 1: Update the CSS for the dropdown menu

.dropdown-menu {   position: fixed; }

Step 2: Add an ID to the button triggering the dropdown

<button type="button" class="btn btn-icon" id="dropdown-button" aria-label="btnGroup" data-toggle="dropdown">

Step 3: Implement the JavaScript function

$('#dropdown-button').click(function() {
  dropDownFixPosition($('#dropdown-button'), $('.dropdown-menu'));
});
function dropDownFixPosition(button, dropdown) {
  var dropDownTop = button.offset().top + button.outerHeight();
  dropdown.css('top', dropDownTop + "px");
  dropdown.css('left', button.offset().left + "px");
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Click on a hyperlink to open a fresh page in a separate tab using Google Chrome

Is there a way to open a link in a new tab instead of a new window on ajax success in Chrome using jQuery or JavaScript? Here is the code snippet: $("#A1").click(function (event) { $.ajax({ type: "POST", url: "Home.aspx/btnTestProje ...

What are the steps to overlay a button onto an image with CSS?

As a CSS newbie, I have a question that may seem silly or straightforward to some. I am struggling with placing a button over an image and need guidance on how to achieve this effect. Specifically, I want the button to appear like this blue "Kopit" button ...

What is the method used by flexbox to determine the width of a flex-item when neither flex-basis nor width is specified?

Can you explain how flexbox calculates the final width of flex-items when specific properties like flex-basis, width, min-width, or max-width are not set? I'm curious about how flexbox determines the width based solely on content. Check out this exam ...

Is there a way to connect a CSS external file that is saved on Dropbox?

Is it possible to link an external CSS file stored in Dropbox with HTML? I have followed all the instructions I could find online, including clicking and pressing "Copy Dropbox Link" to generate an href link. However, it doesn't seem to be working. ...

CSS: Adjusting alignment differences between local host and server

I've been working on a webpage with rotating background images, and everything looked perfect on my localhost. But once I uploaded it to the server and viewed it in different browsers, some of the people in the images were not positioned as intended, ...

Appear and disappear gradually when hovering

When hovering over #one, the class .hidden is applied to #first. I have added a script to make .hidden fade out using transition: ease-in 0.3s;, but I am having trouble getting the fade in effect to work. I attempted adding transition: ease-in 0.3s; to #fi ...

Why is my DIV not registering clicks when I try to interact with it?

Trying to implement a Javascript click event <script type="text/javascript"> $(document).ready(function () { $(".role").click(function () { alert("idiot"); }); }); </script> Here is the CSS code for styling the DIV with clas ...

Having trouble with the vertical-align property in Google Chrome?

<html> <head> <style> table,td {border:1px solid black ;} table {width : 80% ;height:80%;} .top {vertical-align:top}; .center {vertical-align: middle}; .bottom {verti ...

Limit the precision of decimal number output to a specific value

I need assistance with achieving the output 999999.35 in angular or javascript combined with html. I am looking to restrict the number of 9's to a maximum of 6 digits before the decimal point, and after 6 digits it should not accept any more digits. A ...

Submitting a PHP form by uploading an image with AJAX

I'm looking to submit form data to a MySQL database using AJAX. While I'm not very familiar with AJAX, I managed to write a code that successfully submits text data to the database. However, I'm facing issues with uploading and storing image ...

Elevate the value of a particular element's variable through the execution of a function

By using a for loop, I was able to generate a variable number of divs that change their background color individually when hovered over with the mouse. Now, I want to implement a function that will decrease the brightness of each div by 10% every time it i ...

Tips on assigning a reference to an element that has not been rendered yet

I've created a login page with a button labeled "Watch the video". When the button is clicked, it hides and reveals a video player. My goal now is to automatically start playing the video once it's displayed without requiring an extra play button ...

Explore the Filter List without being affected by the arrangement of words or the level of search precision

I was able to resolve the issue by adjusting my search filter algorithm. Now, I can search regardless of word order, but the results are not as specific as I need them to be. When I type "Correy" in the search bar, it shows all results containing that wo ...

Utilizing MongoDB for data transfers: uploading and downloading

I successfully configured my localhost to upload files to Mongo DB using server.js //I have configured my ID and PW const mongoURI = "mongodb+srv://myID:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a2cfdbf2f5e2c1ced7d1 ...

Troubles arise when trying to place images next to items in an unordered list

I'm trying to create an unordered list with list items that include images with bullets beside them. However, when I use a background image to achieve this, the image ends up behind the text. If I set the image as a list-style-image, it doesn't l ...

Turn off the background color box with a single click

Whenever I click on a header menu item, the background changes along with it. Is there a way to prevent this from happening? https://i.stack.imgur.com/p6bJ9.png Take a look here ...

Internet Explorer 11 is not interested in giving attention to a disabled element

I'm trying to limit text input to only one of two fields. My approach involves checking the value of a field when it loses focus, and then disabling the other field if the initial one is not empty. Below is an example: HTML: <div class="contain ...

Ways to update the title of a Magento widget

I've added a widget to showcase new products on my Home page and it's displaying perfectly. However, I want to get rid of the title "New Product" that comes with it. This pesky little thing needs to go! https://i.sstatic.net/P0NeS.jpg I'm ...

Tips for accessing and saving content from a JSON file on your local machine into a variable

Hello all, I'm facing an issue with my script where I have a Json store in a variable. I want to save this json data in a local file to create a standalone and user-friendly website without too many components. Currently, my script looks like this: ...

Discovering elements through parent in Selenium

<div> <span>First line</span> <p>Second line</p> <span>Third line</span> <p>Fourth line</p> </div> My goal is to access the elements within the div tag using CSS or XPath selector ...