2011-07-20 14 views
2

jQueryとASP.Net MVCが初めてです。私はjQueryを使用するmvcアプリケーションを開発しています。jQuery datatable reDraw issue

jQuery Datatablesに問題があります。更新メソッドまたは削除メソッドの後で、Datatableを再構築する必要があります。私はjqueryを使用してそれをしましたが、以前のようにDatatableを読み込むことはできません。この問題について私を助けてください。

<table id="ViewxxTable" width="100%"> //Here is the table I want to reconstruct 
    <thead> 
     <tr> 
      <th>SN No</th> 
      <th>Item code</th> 
     </tr> 
    </thead> 
    <tbody> 
<%  
    List<InSys.Models.xxDetailClass> xxdetailLst =  (List<InSys.Models.xxDetailClass>)Session["xxddetailLst"]; 
    foreach (InSys.Models.xxDetailClass grnd in xxdetailLst) 
     { 
%> 
    <tr> 
     <td><%= grnd.SnNo%></td> 
     <td><%= grnd.ItemCode%></td> 
     <td> 
    </tr> 

<% 
     } 
%> 
    </tbody> 
</table> 

jqueryの

oTable = $('#ViewxxTable').dataTable({ 
       "bPaginate": false, 
       "bJQueryUI": true, 
       "bRetrieve": true, 
       "bDestroy": true, 
       "sPaginationType": "full_numbers" 
}); 

答えて

9
$(document).ready(function() { 
    oTable = $("#tableId").dataTable({ 
     "bPaginate": true, 
     "bJQueryUI": true, 
     "bRetrieve": true, 
     "sPaginationType": "full_numbers" 
}); 

$("#tableId").dataTable().fnDestroy(); // destroy the old datatable 
oTable = $("#tableId").dataTable({ 
    "bPaginate": true, 
    "bJQueryUI": true, 
    "bRetrieve": true, 
    "sPaginationType": "full_numbers" 
0

は、関数内であなたのDataTable使う初期のコードを配置し、this-

function IntializeDatatable(tableId){ 
$('#'+tableId).dataTable(); 
} 

が内側削除あなたのtable..likeの再構築後に、その関数を呼び出します。挿入後、私を再構築したDataTableまたはそれはヘッダのみとfoterを示し更新はしている

IntializeDatatable('ViewxxTable'); 
+0

IT-updateメソッド呼び出しの答えのVivekてくれてありがとう....が、そのdid'ntの仕事、データテーブルのデータは、そのヘッダーと写真に含まれる通常のhtmlテーブルに表示されます。 – Samanalaya

+0

$(document).ready(function(){ – Samanalaya