2014-07-12 2 views
0

나는 약간의 정보가있는 테이블을 가지고있다. 처음에는 php-script에서 생성 한 다음 n 초마다 데이터베이스를 검사합니다.테이블 정리 및 절약 정렬

그럼 tablesorter 플러그인을 설치했습니다. 괜찮습니다.하지만 데이터베이스에서 정보를 얻은 후에 (테이블이 여러 필드로 정렬 된 경우) 정렬 "구성"이 재설정됩니다.

saveSort 플러그인에 대한 정보를 찾았으므로 jquery.tablesorter.widgets.js을 다운로드하여 프로젝트에 포함하십시오. 플러그인 설명서에서 나는 how to과 같은 명령어를 발견했습니다.

$("table").tablesorter({ 
    widgets: ["saveSort"] 
}); 

하지만 내 문제는 해결되지 않습니다. 결과를 얻은 후에는 저장된 정렬이 재설정됩니다.

다음
$(document).ready(function(){ 

     $("table").tablesorter({ 
     widgets: ["saveSort"] 
    }); 

    function get_op(){ 

     var dataSend = "to teh mooon"; 

     jQuery.ajax({ 
      type: "POST", 
      url: "get_url", 
      dataType:"html", 
      data:dataSend, 

      success:function(response){ 
       $("#recent_op tbody").html(response); 
       $("#recent_op").trigger("update"); 

      }, 
      error:function (xhr, ajaxOptions, thrownError){ 
       $("#recent_operations").html(thrownError); 
      } 
     }); 

    } 
    setInterval(function(){get_op()}, 10000); 

}); 

내가 사용하는 간단한 테이블입니다 :

그래서, 여기 내 스크립트의 코드입니다.

<table class="table table-bordered table-hover table-striped tablesorter" id = "recent_op"> 
     <thead> 
     <tr> 
      <th>header # <i class="fa fa-sort"></i></th> 
      .... 
      </tr> 
     </thead> 

     <tbody> 
      <tr> 
      <td>Body</td> 
      .... 
      </tr> 
        .... 
      <tr> 
       <td>Body</td> 
       .... 
      </tr> 
     </tbody> 
    </table> 

자습서의 모든 오류는 없지만 제대로 작동하지 않습니다. 나는이 위젯을 잘못된 방식으로 사용하고 있다고 생각합니다.

답변

0

saveSort 위젯이 필요합니다

  • 의 jQuery v1.4.1에서 또한 jquery.tablesorter.widgets.js에 포함되어 +
  • $.tablesorter.storage 유틸리티입니다. 파일을 수정 한 경우에 대비하여이 방법을 설명합니다.
  • localStorage를 지원하는 브라우저 또는 쿠키 (localStorage가 지원되지 않는 경우 대체 방법).
  • 정렬 위젯 옵션

    $(function(){ 
        $("table").tablesorter({ 
        widgets: ["saveSort"], 
        widgetOptions : { 
         // if false, the sort will not be saved for next page reload 
         saveSort : false 
        } 
        }); 
    }); 
    
를 사용하여 활성화/비활성화 할 수 있습니다 막아