2013-05-19 3 views
0

서버 측을 사용하여 데이터 테이블을 채우고 다른 작업을 수행 할 수 있지만 reload_table을 클릭하면 데이터를 새로 고칠 수 없습니다. element.clear 데이터 테이블은 올바르게 작동하지만 그릴 수 없습니다.jQuery datatables 새로 고침 데이터가 작동하지 않습니다

JQUERY :

$('#reload_table').live('click',function(){ 
    oTable_topics.fnReloadAjax(oTable_topics.fnSettings()); 
    oTable_topics.fnClearTable(); 
    oTable_topics.fnDraw(); 
    $.ajax({ 
     url: "server_processing.php", 
     success: function() { 
      // if it worked, ask datatable to redraw the table with the new data 
      $("#showTopics").dataTable().fnDraw(); 
      // if this js function does anything useful (like deleting the row), then call it: 
      Success(); 
     }, 
     error: function() { 
      // display any error (like server couldn't be reached...), or at least try to log it 
     } 
    }); 
}); 
oTable_topics =$('#showTopics').dataTable({ 
     "bLengthChange": false, 
     "iDisplayLength": 12,        
     "bScrollCollapse": true,  
     "bJQueryUI": true, 
     "bAutoWidth": false, 
     "sAjaxSource": "server_processing.php", 
     "sPaginationType": "full_numbers", 
     "bProcessing": true, 

     "fnDrawCallback": function(oSettings) { 
      clickRowHandler_topics(); 
      if (oSettings.aiDisplay.length == 0) 
      { 
       return; 
      }      
      var nTrs = $('tbody tr', oSettings.nTable); 
      var iColspan = nTrs[0].getElementsByTagName('td').length; 
      var sLastGroup = ""; 
      for (var i=0 ; i<nTrs.length ; i++) 
      { 
       var iDisplayIndex = oSettings._iDisplayStart + i; 
       var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[0]; 
       if (sGroup != sLastGroup) 
       { 
        var nGroup = document.createElement('tr'); 
        var nCell = document.createElement('td'); 
        nCell.colSpan = iColspan; 
        nCell.className = "group"; 
        nCell.innerHTML = sGroup; 
        nGroup.appendChild(nCell); 
        nTrs[i].parentNode.insertBefore(nGroup, nTrs[i]); 
        sLastGroup = sGroup; 
       } 
      } 
     }, 
     "aoColumnDefs": [ 
      { "bVisible": false, "aTargets": [ 0 ] } 
     ], 
     "aaSortingFixed": [[ 0, 'asc' ]], 
     "aaSorting": [[ 1, 'asc' ]], 
     "fnServerParams": function (aoData) { 
      aoData.push(
      {"name": "id" ,  "value": "i.id" },   
      {"name": "subject" , "value": "i.subject" }, 
      {"name": "date_time", "value": "i.date_time"} , 
      {"name": "posted_by", "value": "u.username"} , 
      {"name": "ctitle" , "value": "c.title"} , 
      {"name": "etitle" , "value": "e.title"}, 
      {"name": "istatus" , "value": "i.status"}, 
      {"name": "join"  , "value": "JOIN categories c ON i.category = c.id JOIN status_topics e ON i.status = e.id JOIN users u ON i.posted_by = c.id"}, 
      {"name": "action" , "value": "topics" } 
     )} 
     }); 
+0

.live은 – underscore

+0

@SamithaHewawasam에 사용하십시오되지 않는, 예를하지만 내 문제는 테이블을 다시 그리기입니다되었습니다. –

+0

mahdi, 아마도 http://datatables.net/forums/에도 문의해야합니다. – Stano

답변

0

나는 그것을 생각하면서 페이지 길이를 변경하려면 새로운 데이터를로드 할 fnReloadAjax를 사용 fnLengthChange되었다.

oTable.fnClearTable(0); 
oTable.fnReloadAjax('/' + myLocation + '/' + myCustomerId); 
oTable.fnLengthChange(pageLength); 
관련 문제