0

i have a select-box with option1 and option2; i have a table with column1, column2, column3, column4. Column2 and column3 are numeric fields.

1) i want that i selected option1 in select-box, the table show the rows that all fileld in column2 are >0 and all fields of column3 are == 0

2) i want that i selected option2 in select-box, the table show the rows that all fileld in column2 are ==0 and all fields of column3 are > 0

example

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> 

Thank you for help

1
  • 2
    Can you post a working jsfiddle, with your controller code?CommentedMar 23, 2017 at 11:53

1 Answer 1

1

Using angular "filter" filter.

Put this in your controller

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; } }; 

Change this in Template:

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

Something like this should work, I couldn't test it because I don't have test data. If you have any problems with this please add a jsfiddle and I'll have a look at it.

0

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.