title: How to hide DataTables export button if no data?
body: <p>I am doing project in laravel. I have implemented DataTables as,</p>
  
  <p><strong>blade.php</strong></p>
  
  <pre><code>&lt;table id="userprofaneword-table" class="table table-condensed table-hover"&gt;
       &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;{{ trans('labels.backend.report.profaneword.table.id') }}&lt;/th&gt;
              &lt;th&gt;{{ trans('labels.backend.report.profaneword.table.user') }}&lt;/th&gt;
          &lt;/tr&gt;
       &lt;/thead&gt;
       &lt;tbody&gt;
            @foreach($profaneData as $profaneUser)
                 &lt;tr&gt;
                     &lt;td&gt;{{$profaneUser-&gt;user-&gt;id ?? '---'}}&lt;/td&gt;
                     &lt;td&gt;{{$profaneUser-&gt;user-&gt;first_name ?? '---'}}
                     &lt;/td&gt;
                 &lt;/tr&gt;
            @endforeach
       &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>Scripts</strong></p>
  
  <pre><code>{{ Html::script("https://cdn.datatables.net/v/bs/dt-1.10.15/datatables.min.js") }}
  {{ Html::script("js/backend/plugin/datatables/dataTables-extend.js") }}
  
  {{ Html::script("https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js") }}
  {{ Html::script("https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js") }}
  {{ Html::script("https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js") }}
  
  &lt;script&gt;
      $(function () {
          $('#userprofaneword-table').DataTable({
              "dom": "Bfrtip",
              "lengthChange": true,
              "autoWidth": true,
              "searching": true,
              "order": [[ 0, "desc" ]],
              "language": {
                  "searchPlaceholder": "Search",
              },
              "buttons": [
                  {
                      "extend": 'excelHtml5',
                      "text": 'Export User Profanity Report',
                      "className":"btn btn-sm btn-primary pull-right",
                      "exportOptions": {
                       "columns": ":not(:last-child)",
                      }
                  }
              ],
              "select": true,
              "searchDelay": 500
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Every thing works fine. I can export data from table, I just want <strong>hide export button if there is no data</strong> coming from controller.</p>