2012-11-26 18 views
9

私は、Angularと共に動作するJQuery tablesorterプラグインを使用しようとしています。 現在、並べ替えの列をクリックすると、テーブルの幅と構造全体が変更され、ng-repeat式の新しい行が作成されます。AngularjsでjQuery tableSorterプラグインを使用する

$(document).ready(function() { 
    $("#check").tablesorter(); 
}); 

 

<table id="check" class="table table-bordered table-striped table-condensed table-hover tablesorter" cellspacing="1"> 
    <thead> 
     <tr>   
      <th class="header">Product Code#</th> 
      <th class="header">Item Description#</th> 
      <th class="header">Unit Cost#</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr ng:repeat="i in itemresponse" > 
      <td><a href="#/ItemSearch/{{i._ItemID}}" >{{i._ItemID}}</a></td> 
      <td>{{i.PrimaryInformation._ShortDescription}}</td> 
      <td>{{i.PrimaryInformation._UnitCost}}</td> 
     </tr> 
    </tbody> 
</table> 
+2

まず、tablesorter呼び出しをディレクティブに移動します。 ng:repeatが呼び出された後に呼び出されるディレクティブの優先順位を変更することができます。 http://youtu.be/iB7hfvqyZpg –

+2

を参照してください。http://docs.angularjs.org/api/ng.filter:orderByの例をご覧ください。TablesorterなしでAngularJSを使用してソート可能なテーブルを作成することは可能です。 –

+0

これは万一の場合に役立ちますか?http://plnkr.co/edit/VOf0DjZiKA2VxrWUDUgj?p=preview – eugenekgn

答えて

5

あなたは間違ってそれをやっています。

AngularJSを使用してテーブル内の行を並べ替える場合は、orderByフィルタを使用する必要があります。別のフレームワークを含める必要はありません。その飛躍を遂げると、オンラインで(またはSO上で)多数のサンプルを見つけることができます。

例えば、このフィドルを参照してください:http://jsfiddle.net/uRPSL/1/

2

は幸いな角度モジュールがng-tableと呼ばれるがあります。

関連する問題