Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put Processing message at the top of table in datatables with existing data?

In my laravel 5.7 application I use "yajra/laravel-datatables-oracle": "~8.0" library and reading this https://m.datatables.net/forums/discussion/25666/how-to-customize-the-processing-message

I modified processing message with style :
.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;
}

and it works and I retrieve data on page open with empty data area.

But I refresh data I do not see processing message : it is below(looks like middle of the data area). I tried to raise with adding to style above :

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

But failed.

The html-code of my data area is :

<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>
         <tr role="row">
            <th class="details-control sorting_disabled" rowspan="1"
                colspan="1" style="width: 47px;">+
            </th>
            <th class="sorting" tabindex="0"
                aria-controls="get-vote-dt-listing-table" rowspan="1"
                colspan="1" style="width: 59px;">Id
            </th>
            <th class="sorting" tabindex="0"
                aria-controls="get-vote-dt-listing-table" rowspan="1"
                colspan="1" style="width: 106px;">Name
            </th>
            <th class="sorting" tabindex="0"
                aria-controls="get-vote-dt-listing-table" rowspan="1"
                colspan="1" style="width: 113px;">Status
            </th>
            <th class="sorting" tabindex="0"
                aria-controls="get-vote-dt-listing-table" rowspan="1"
                colspan="1" style="width: 125px;">Is Quiz
            </th>
            <th class="sorting" tabindex="0"
                aria-controls="get-vote-dt-listing-table" rowspan="1"
                colspan="1" style="width: 219px;">Vote Category
            </th>
            <th class="sorting" tabindex="0"
                aria-controls="get-vote-dt-listing-table" rowspan="1"
                colspan="1" style="width: 178px;">Created At
            </th>
            <th class="sorting_disabled" rowspan="1" colspan="1"
                style="width: 28px;"></th>
            <th class="sorting_disabled" rowspan="1" colspan="1"
                style="width: 29px;"></th>
         </tr>
         </thead>
         <tbody></tbody>
      </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>

Which is right way with style modifications?

Uploaded block # 1

I uploaded live example at http://demo2.nilov-sergey-demo-apps.tk/login

It is under credentials [email protected] 111111 after that http://demo2.nilov-sergey-demo-apps.tk/admin/box-rooms

on uploading page message is visible within 1-2 seconds

If in filter field “Enter Box Room No.” enter value “001” and click “Search” I added 30 seconds delay for debugging in browser. You need to scroll down to see processing message...

Thanks!

like image 540
mstdmstd Avatar asked Feb 02 '19 12:02

mstdmstd


People also ask

What is deferLoading in DataTable?

deferLoading is used to indicate that deferred loading is required, but it is also used to tell DataTables how many records there are in the full table (allowing the information element and pagination to be displayed correctly).

What is stateSave in DataTables?

DataTables saves the state of a table (its paging position, ordering state etc). When the stateSave option is enabled, it can be restored when the user reloads a page, or comes back to the page after visiting a sub-page.

What is aaData DataTable?

By default DataTables will use the "aaData" property of the returned data which is an array of arrays with one entry for each column in the table.

What does DataTable destroy do?

The destroy event is fired when a DataTable is torn down, to be replaced with an enhanced HTML table (or simply removed from the DOM altogether). This can be used to remove bound events, added DOM nodes etc and can be particularly useful for plug-in authors.


2 Answers

To put the processing message at the top of the datatables and not in the middle you could do it this way using div.dataTables_wrapper div.dataTables_processing and top:0 (or top:-10 if you want to see the headers while the table is loading) :

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

JSFiddle : https://jsfiddle.net/0usjep4r/

(The DataTables ajax request is the courtsy of gyrocode and it was created by him. I simply modified it to get the desired result.)

like image 80
Alexandre Elshobokshy Avatar answered Oct 16 '22 17:10

Alexandre Elshobokshy


The problem with only adding top: 0 is that you obscure your 'Show [num] entries' widget:

enter image description here

In a production application, it's typically considered bad UX to obscure widgets that might later be used by customers. If you agree, you'll want to add a few more things:

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

This allows for the 'Show [num] entries' to once again be visible:

enter image description here

like image 2
Andy Hoffman Avatar answered Oct 16 '22 19:10

Andy Hoffman