2017-03-23 10 views
0

私はオプション1とオプション2を持つ選択ボックスを持っています。 私は、column1、column2、column3、column4のテーブルを持っています。 Column2とColumn3は数値フィールドです。2列のAngularJSカスタムフィルタ

1)私は私が選択したことにしたい)テーブルには、column2の中のすべてのfileldは> 0であり、COLUMN3のすべてのフィールドが== 0

2ある行を示し、私は選択ボックスでオプション1を選択することを望みますオプション2は、選択ボックスで、テーブルにはCOLUMN2内のすべてのfileldは== 0の行を示し、COLUMN3のすべてのフィールドは例

select class="form-control" name="optionsSelect" ng-model="ctrl.table.filterParams.optionSelect" 
     ng-options="option for option in ctrl.ctx.option"> 
</select> 

<div class="bt-table"> 
    <table class="table table-striped" ng-table="ctrl.tableParams" id="exampleTable"> 
     <thead> 
     <tr> 
      <th ng-repeat="item in items"><p ng-bind-html="item"></th> 
     </tr> 
     </thead> 
     <tbody> 
     <tr ng-repeat="item in ctrl.table.data"> 
      <td><a>{{item.column1}}</a></td> 
      <td>{{item.column2}}</td> 
      <td>{{item.column3}}</td> 
      <td>{{item.column4}}</td> 
      <td>{{item.column5| date: 'dd/MM/yyyy'}}</td> 
      <td>{{item.column6| currency : "" | currencyformat }}</td> 
     </span></td> 

      <td>{{item.column7}}</td> 
      <td>     
      {{item.column8}} 
      </td> 
     </tr> 
     </tbody> 
    </table> 

> 0

が助けてくれてありがとうです

+2

コントローラコードを使用して作業中のjsfiddleを投稿できますか? –

答えて

1

角フィルタフィルタを使用しています。このような何かが動作するはずです私が持っていないので、私はそれをテストすることができませんでした

<tr ng-repeat="item in ctrl.table.data | filter:ctrl.filterCriteria"> 

ctrl.filterCriteria = function (item) { 
    if (ctrl.table.filterParams.optionSelect == option1) { 
     return item.column2 > 0 && item.column3 == 0; 
    } else if (ctrl.table.filterParams.optionSelect == option2) { 
     return item.column2 == 0 && item.column3 > 0 
    } else { 
     // Display all items 
     return true; 
    } 
}; 

をあなたのコントローラにテンプレートの変更、これをこれを入れてテストデータ。これに問題がある場合は、jsfiddleを追加してください。私はそれを見ていきます。

+0

great Nik!できます! – Alex

関連する問題