Is it possible to display a Processing message at the beginning of a datatables table already containing data?

Within my Laravel 5.7 application, I have implemented the "yajra/laravel-datatables-oracle": "~8.0" library and found a helpful thread on customizing the processing message at this link.

I adjusted the processing message styling as follows:
.dataTables_processing {
  margin-top: -80px !important;
  padding: 70px !important;
  background: #F5F8FA !important;
  color: blue !important;
  border: 2px dotted darkgrey;
  border-radius: 3px !important;
  font-size: xx-large !important;
  opacity : 1 !important;
  text-decoration: none;
}

This modification successfully displayed the processing message when loading data on page open, however subsequent data refreshes did not show the message in the desired position.

I attempted to adjust the vertical alignment by adding the following to the existing style:

  vertical-align: top;
  vert-align: top;

This adjustment did not yield the expected result.

The HTML structure of the data area is as follows:

<div class="table-responsive">
   <div id="get-vote-dt-listing-table_wrapper"
        class="dataTables_wrapper no-footer">
      <div id="get-vote-dt-listing-table_filter" class="dataTables_filter"
           style="display: none;"><label>Search:<input type="search" class=""
                                                       placeholder=""
                                                       aria-controls="get-vote-dt-listing-table"></label>
      </div>
      <div id="get-vote-dt-listing-table_processing"
           class="dataTables_processing" style="display: block;">Loading
         votes...
      </div>
      <table class="table table-bordered table-striped text-primary dataTable no-footer"
             id="get-vote-dt-listing-table" role="grid"
             aria-describedby="get-vote-dt-listing-table_info">
         <thead>
         ...
            // Table content omitted for brevity
         ...
      </table>
      <div class="dataTables_info" id="get-vote-dt-listing-table_info"
           role="status" aria-live="polite" style="display: none;"></div>
      <div class="dataTables_paginate paging_simple_numbers"
           id="get-vote-dt-listing-table_paginate"></div>
   </div>
</div>

What would be the correct method for achieving the desired style modifications?

Uploaded block # 1

You can view a live example at this link. Log in with credentials [email protected] 111111, then navigate to this page.

The processing message should display within 1-2 seconds upon page upload. If you enter "001" in the filter field labeled “Enter Box Room No.” and click “Search”, there is a deliberate 30-second delay added for debugging purposes. Scroll down to observe the processing message...

Thank you!

Answer №1

If you want to place the processing message at the top of the datatables instead of in the middle, you can achieve this by using

div.dataTables_wrapper div.dataTables_processing
and applying top: 0 (or top:-10 if you prefer to see the headers while the table is loading):

div.dataTables_wrapper div.dataTables_processing {
  top: 0;
}

You can view the code on JSFiddle here: https://jsfiddle.net/0usjep4r/

(Credit for the DataTables ajax request goes to gyrocode. I made modifications to achieve the desired outcome.)

Answer №2

The issue arising from solely including top: 0 is the potential obstruction of the 'Show [num] entries' tool:

https://i.sstatic.net/4Ppnw.png

In a live application, it's generally agreed upon that concealing tools that may be utilized by users later on leads to poor user experience. If you share this view, implementing a few additional modifications can rectify this problem:

#get-storage-space-dt-listing-table_processing {
  top: -10px;
  width: auto;
  margin: 0;
  transform: translateX(-50%);
}

By doing so, the 'Show [num] entries' feature becomes visible once more:

https://i.sstatic.net/6dnuR.png

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

Issue with bouncing dropdown menu

I am in the process of enhancing a Wordpress website by implementing a jQuery menu with sub-menus. Below is the jQuery code snippet: $(document).ready(function(){ $('.menu > li').hover(function(){ var position = $(this).position(); ...

What is the best approach to styling a sub-child element within the first child using TailwindCSS?

Currently working with React (Next.js) and TailwindCSS. <ul> <li> <h1 className="bg-red-400">first</h1> </li> <li> <h1 className="bg-green-400">second</h1> </li> &l ...

Looking to Identify a Click Within a Complicated Component and Retrieve the Component's ID

Currently, I am working with React for development and have a need to capture clicks at the topmost parent level for performance reasons. const clickHandler = (e) => { console.log("clickHandler", e.target) --> I want to identify the child ...

What is the best way to embed an image into HTML code?

I am trying to enhance the appearance of a phone number inside an HTML code that is loaded into a UIWebView by adding a background image. NSString *stringToReplace = [NSString stringWithFormat:@"<a style=\"color:white; background-color:#707070; te ...

perform one task following the completion of another

Can I run the second function after the first one without using a timeout event in this JavaScript code: if (direction !== "leftnav") { // DO THINGS }; setTimeout(function () { //DO OTHER THINGS AFTER THE FIRST THING }, 1000); Your input is greatly app ...

"Utilize the on() method to bind a click event to dynamically generated elements received

After reading several discussions on using on() to link events to dynamically generated HTML elements, I decided to create an example (FIDDLE) where the click event is bound to elements div.clicktitle fetched via AJAX. These div elements contain data attri ...

Tips for repairing a side bar and header with CSS when using a JS & jQuery scroller

I am working on a layout design and my goal is to have the left sidebar, right sidebar, and header remain fixed in place. Here is the CSS code I am using : #container { padding-left: 200px; /* Left Sidebar fullwidth */ padding-ri ...

Upon encountering an expression, the code anticipated either an assignment or a function call, but instead found an expression, triggering the no

When using the forEach method within a function in JavaScript, I encountered a code compilation failure with the following error: Expected an assignment or function call and instead saw an expression no-unused-expressions. This error occurs for both ins ...

What are the steps to effectively implement the useEffect hook in React?

I'm facing an issue where I am trying to return a function that utilizes useEffect from a custom usehook, but I keep getting the error "useEffect is called in a function which is neither a react function component nor a custom hook." Here's what ...

How can I use React to switch the visibility of a nested component from the parent container component?

Objective I am in the process of replicating a List Control Component using React and Redux, following the guidelines outlined in Google Material Design layout. This list control will enable users to create, rename, and delete items within the list witho ...

Identify specific elements using CSS to easily target them with JavaScript later on

Currently, I am utilizing CSS selectors to target specific elements and now I want to be able to identify those elements using javascript. My approach involves setting the color of these elements in css and then retrieving them based on their color. Howeve ...

Ways to verify the occurrence of a successful event following the execution of a save() operation on a model

Below is the snippet of code I am using to store extra properties in a model (specifically, the answer model) selectMedia: => # Post media to server @options.answer.id = @options.answer.get('_id') @options.answer.url = "/v1/answers/#{@o ...

Is there a way for my website visitors to seamlessly download the font I use if it's not already installed on their devices?

I've chosen the unique font ff-clifford-eighteen-web-pro-1 for my website. I'm looking to ensure that all text is consistently displayed in this font, even for users who may not have it downloaded on their device. Is there a way to make this hap ...

Different methods to retrieve content within a div that is located on a separate, included page

It's a bit tricky to come up with a title for this topic, but essentially, I'm trying to figure out how to get content from an included page into a specific div using HTML and PHP. Let me break it down: In the header.php file, we have the follo ...

Upon concatenation, the screen automatically returns to the beginning of the page

I've set up a page with a list of items, and at the bottom there's a handy "Load more" button that fetches new items to add on top of the existing list: handleLoadProducts = (append = false) => { this.setState({ isLoading: true, ...

Using PHP to dynamically change the title of a Bootstrap modal

I've been attempting to dynamically update the title of my modal using PHP. The title I wish to display is stored in a variable and is being reassigned based on user input. Below is my PHP code snippet: $studentName = $results['Studentname&apo ...

My footer is now overlaying both my content and navbar

I am facing an issue with my footer. When I test my new footer, it ends up covering the content and navbar. I have been trying to figure out how to solve this problem but haven't had any luck yet. Hopefully, I can find some answers here... $(".toge ...

``There seems to be an issue with the functionality of Passport.js' multiple login system

I'm encountering a strange issue with my login system. Everything seems to be working fine, including local login, Google login, and Facebook login. However, the problem arises when I attempt to register with Google after already registering with Face ...

What is the best way to align my progress bar to the bottom of a button?

I've encountered a small issue that I'm struggling to resolve. My goal is to create a button with a Bootstrap progress bar at the bottom, but I can't seem to make it work as intended. Here's the current setup: https://jsfiddle.net/bob ...

Steps to dynamically adjust an element's width in CSS depending on the presence of a separate element

I have a text input box appearing on the left side with a button positioned next to it on the right. For certain pages, I want to display a checkbox next to the input box and move the button below it. Is there a way to achieve this using CSS flexbox or a ...