What could be causing angular-datatable to not properly fill columns in Bootstrap 4?

I have been attempting to create a responsive table using angular-datatables (for angular 7) and bootstrap 4, but I am encountering issues with the current appearance of the table:

Current HTML code:

<div class="row">
                        <div class="col-12">
                            <div class="table-responsive">
                                <table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="table table-hover table-bordered">
                                    <thead class="thead-colored thead-primary">
                                        <tr class="text-center">
                                            <th>ID</th>
                                            <th>NICKNAME</th>
                                            <th>EMAIL</th>
                                            <th>REGISTRATION</th>
                                            <th>STATUS</th>
                                            <th>HIGH</th>
                                            <th>ACTIONS</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr *ngFor="let user of usersArray" class="text-center">
                                            <td>{{user.ID}}</td>
                                            <td>{{user.NICKNAME}}</td>
                                            <td>{{user.EMAIL}}</td>
                                            <td>{{user.REGISTRATION | date: 'dd-MMMM-yyyy' | uppercase}}</td>
                                            <td>
                                                <span class="bg-success pd-y-3 pd-x-10 text-white tx-11 tx-roboto">
                                                            {{user.STATUS | toStatusReadable}}
                                                        </span>
                                            </td>
                                            <td>{{user.ACCESS_PROVIDER}}</td>
                                            <td>
                                                <div type="button" class="dropdown">
                                                    <a [routerLink]="" class="tx-gray-800 d-inline-block" data-toggle="dropdown">
                                                        <div class="ht-45 pd-x-20 bd d-flex align-items-center justify-content-center">
                                                            <span class="mg-r-10 tx-13 tx-medium">Options</span>
                                                            <img src="https://via.placeholder.com/500" class="wd-25 rounded-circle" alt="">
                                                            <i class="fas fa-angle-down"></i>
                                                        </div>
                                                    </a>
                                                    <div class="dropdown-menu pd-10 wd-200">
                                                        <nav class="nav nav-style-2 flex-column">
                                                            <a [routerLink]="" class="nav-link"><i class="icon fas fa-edit"></i> Edit data</a>
                                                        </nav>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

TS File code for the table:

export class AdministratorsComponent implements OnInit, OnDestroy {
  dtOptions: any = {};
  dtTrigger: Subject<any> = new Subject<any>();

  usersArray: Array<Users> = [];

  constructor(
    private devInfo: DevelopmentService,
    private dtService: DatatableService,
    private administratorsService: AdministratorsService
  ) {
    this.GetSmartliveUsers();
  }

  ngOnInit() {
    document.getElementById('mainSystemPanel').removeAttribute('class');
    document.getElementById('mainSystemPanel').className = 'br-mainpanel';
    this.dtOptions = this.dtService.getDataTableConfig();
  }

  ngOnDestroy() {
    this.dtTrigger.unsubscribe();
  }

  async GetSmartliveUsers() {
    const users = <any []> await this.administratorsService.getSmartliveUsersList();
    for ( let i = 0; i < users.length; i++) {
      this.usersArray.push(JSON.parse(users[i]));
    }
    this.dtTrigger.next();
  }
}

The service providing the table configuration:

export class DatatableService {

  constructor() {
  }

  getDataTableConfig() {
    return {
      language: {
        url: 'assets/content/smartlive/spanish.json'
      },
      responsive: true
    };
  }
}

angular.json snippet:

"styles": [
                            "node_modules/@fortawesome/fontawesome-free/css/all.min.css",
                            "node_modules/animate.css/animate.min.css",
                            "src/assets/content/template/lib/ionicons/css/ionicons.min.css",
                            "src/assets/content/template/lib/rickshaw/rickshaw.min.css",
                            "src/assets/content/template/lib/select2/css/select2.min.css",
                            "src/assets/content/template/css/bracket.css",
                            "src/assets/content/template/css/bracket.oreo.css",
                            "node_modules/datatables.net-dt/css/jquery.dataTables.min.css",
                            "node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css",
                            "node_modules/datatables.net-responsive-dt/css/responsive.dataTables.min.css",
                            "src/styles.css"
                        ],
                        "scripts": [
                            "node_modules/jquery/dist/jquery.js",
                            "node_modules/datatables.net/js/jquery.dataTables.js",
                            "node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js",
                            "node_modules/datatables.net-responsive/js/dataTables.responsive.min.js"
                        ]

I have installed all necessary package files for the datatable, but I am struggling with achieving correct 100% width and the positioning of the pagination and search input over the table.

Answer №1

While it may be overdue, this information could benefit someone else ;-)

Give this a shot:

npm install datatables.net-bs4

After that, make sure to include the following lines in your code:

"styles": [
   ...
   "./node_modules/datatables.net-bs4/css/dataTables.bootstrap4.min.css",
   ...
],
"scripts": [
   ...
   "./node_modules/datatables.net-bs4/js/dataTables.bootstrap4.min.js",
   ...
],

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

The module cannot be located due to an error: Package path ./dist/style.css is not being exported from the package

I am facing an issue with importing CSS from a public library built with Vite. When I try to import the CSS using: import 'rd-component/dist/style.css'; I encounter an error during the project build process: ERROR in ./src/page/photo/gen/GenPhot ...

I am interested in extracting information from the Firebase real-time database and showcasing it on my HTML webpage

I am struggling to display data from the Firebase real-time database on my HTML page. Even though I can see all the data perfectly in the console, it doesn't show up on the webpage. I attempted to use a for loop, but it still doesn't display the ...

Aligning text with a scalable vector graphic (SVG) illustration

Is there a way to position the text next to the SVG object? The current output is as follows: The desired outcome is to have the text displayed alongside the SVG image: Below is the HTML code snippet: <div class="alert alert-success smallFont" id="i ...

Updating style of element in EJS following POST request in Node.js using Express

I am working on a form page that is supposed to display a Success Alert (Boostrap) once the user fills out the form and clicks the Submit button. <form class="well form-horizontal" action="/contact" method="post" id="contact_form"> ... (input fiel ...

Basic progress bar

I'm attempting to create a basic download bar, but it's only displaying as a solid color without any transition animation. Furthermore, the "repeating-linear-gradient" feature isn't functioning and I'm struggling to figure out why. I&a ...

Prevent global CSS from affecting VueJS by enabling only scoped CSS within components

Is there a way to eliminate all global CSS within a VueJS component and only allow scoped CSS? If so, how can this be achieved? Below is the issue I am trying to address: * { /* Global styles */ } /* Component-specific styles */ .items ul { } .i ...

AngularJs - Show the response only upon verifying the correct answer

Let me provide an overview of what has been implemented so far: When a user selects an answer in radio buttons and clicks on "Check Answer", the system displays either "Correct" (in green) or "Incorrect" (in red) in the first answer field. Additionally, th ...

difficulties arise when adjusting font size in html and css

When I first created an all HTML/CSS website, I used clickable images as a menu that scaled perfectly on all monitors and browsers. Now, for my new project, I wanted to use a background image for the menu with hyperlinked text on top. I thought setting the ...

Bordering the isotopes

Currently, I am utilizing a plugin that involves the isotope filter library. By setting the width to 33.33%, my list elements are organized into 3 columns. I am trying to specify the middle column to have side borders. However, whenever I click on the filt ...

Incorporate a local asciinema file into an HTML document

Is there a way to embed a local asciinema session into an html file? Here is how my directory is structured: $ tree . ├── asciinema │ └── demo.cast ├── css │ └── asciinema-player.css ├── index.html ├── js │ ...

Creating UL tabs using just HTML and CSSHere's a step-by-step guide

Looking for help to accomplish this task. I already have the styling, but I want something to happen when I click on the tabs. Specifically, I want the div with the tab class names to show and hide upon clicking the tabs. Currently, nothing happens when I ...

Having trouble with CSS media queries not functioning properly on Internet Explorer version 9?

Incorporated media queries in my design to adjust the width of certain elements on the page according to the browser's width. These are the queries I am using: @media screen and (min-width:1024px) @media screen and (max-width:1024px) Chrome, Safari, ...

Test your knowledge of Javascript with this innerHtml quiz and see

How can I display the output of a score from a three button radio button quiz without using an alert popup? I want the output to be displayed within a modal for a cleaner look. I tried using InnerHTML but now there is no output when the button is clicked. ...

Alphabetically sorting objects in an array using Angular

If your TypeScript code looks something like this: items: { size: number, name: string }[] = []; ngOnInit(): void { this.items = [ { size: 3, name: 'Richard' }, { size: 17, name: 'Alex' }, ...

React Tabulator - custom header filter for select column - hide 'X' option

Is it possible to remove the 'x' option on header filters in react tabulator columns? The issue arises when users click the 'X' to clear a filter, as expected. However, if they then try to click on the same filter for another list item ...

Using AngularJS to update attributes in an HTML tag within a string

My string contains HTML tags : var str = "<div><p></p><p><i>blabla</i></p><p><i><b>blaaaaaablaaaaa</b></i></p><iframe src='urlAAA' height='400' width=&ap ...

Currently, I am in the process of constructing a DSpace repository on an Ubuntu 16.04

I have successfully set up a DSpace repository on Ubuntu 16.04 LTS by following the installation instructions provided in this manual. After deploying the webapps, I encountered an issue when trying to add new items. Upon clicking the search link, I recei ...

The hamburger icon seems to be frozen and unresponsive

I'm struggling to get my hamburger icon to reveal the navigation bar when clicked. The icon itself functions properly and adapts to different screen sizes, but the overlay remains stationary. Check out my code on JSFiddle! <html> <head> ...

Is it possible to include all the information in a form submission, not just the inputs?

I have a problem with submitting the form and accessing all the variables I need. When I check the $_POST variable, I only see the values of the form inputs. Is there a way to also send other variables like the content of multiplicator1? How can I achiev ...

Add Your Logo to the Navigation Bar using CSS

Can someone please assist me with adding a logo to my CSS navbar? I am struggling to figure out how to do this and would appreciate any guidance or tips on how to successfully implement a logo in the navbar. body { margin: 0px; } ul { list-style-ty ...