2016-04-22 29 views
0

jquery DataTable v 1.10.11を使用しています。データテーブルがajax呼び出しでデータを読み込んでいる間に、テーブル全体とdivを非表示にしたいと思います。私はadd/edit/deleteのような同じテーブルで多くのタスクを実行しているので、私はできないajax呼び出しの成功のテーブルを初期化するための提案を見つけました。以下は私のdataTable宣言です。以下は読み込み中にDataTableを非表示にする

$(document).ready(function(){ 
//some code .... 

var listTable = $('#listTable').DataTable({ 
       'fnCreatedRow': function (nRow, aData, iDataIndex) { 
       $(nRow).attr('id', 'my' + iDataIndex); 
       $(nRow).attr('name', 'my' + iDataIndex); // or whatever you choose to set as the id 
       }, 
       "tableTools": { 
         "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf", 
         "aButtons": [ 
          { 
           "sExtends": "copy", 
           "sButtonText": "Copy To ClipBoard", 
          }, 
          { 
           "sExtends": "xls", 
           "sFileName": "*.xls", 
           "sButtonText": "Download XLS", 
          }, 
          { 
           "sExtends": "print", 
          }       
        ] 
        }, 
        "bInfo": false, 
        "sEmptyTable": "There are no records", 
        "processing": true, 
        "oLanguage": { 
         "sProcessing": "<img src='${request.contextPath}/images/ajax-loader.gif'>" 
       }, 
       "dom": '<"toolbar">T<"clear">lfrtip', 
       "order": [[ 1, "desc" ]] 
    }); 

    $('.dataTables_empty').html(""); 

//some more code 
//some url 
listTable.ajax.url(url).load() 

    }); 

現在、私は、DataTableには、ロード中にGIFローディング画像を表示することができていますテーブルのHTMLコード

<div id="data_table_travelHistory" style="margin:0 auto; padding-top:10px; width:90%;"> 
       <table cellpadding="0" cellspacing="0" border="0" id="listTable" style="width:100%;" class="table table-striped table-bordered"> 
       <thead class="alignCenter"> 
       <tr> 
      <th class="headerclass">Start Date</th> 
      <th class="headerclass">Approval Status</th> 
      <th class="headerclass">Created On</th> 
      <th class="headerclass">Action</th> 
       </tr> 
       </thead> 
       <tbody></tbody> 
       <tfoot class="alignCenter headerclass"> 
       <tr> 
      <th class="headerclass">Start Date</th> 
      <th class="headerclass">Approval Status</th> 
      <th class="headerclass">Created On</th> 
      <th class="headerclass">Action</th> 
       </tr> 
       </tfoot> 
       </table> 
      </div> 

です。しかし、初期化されたテーブルは、常に見栄えの悪いバックグラウンドで表示されます。 DataTableとdivの全体を非表示にしてローディングバーのみを表示する方法はありますか?どんなヘルプもあります...

答えて

0

readyイベントでテーブルを初期化してから、 ajaxリクエストの最後にテーブルを表示/非表示にするcssクラスを削除します。

+0

gifは同じコンテナ内にあり、同じ方法でgifを表示/非表示にすることができます。 –

関連する問題