带有多个输入的过滤表,带有“或”操作者 [英] Filter table with multiple input with "or" operator
问题描述
我有2个输入字段,我想使用OR而不是And来过滤2个输入字段。
但是我无法使用下面的代码执行此操作,无论我在输入中键入什么内容,表格都返回所有字段,任何人都可以帮助我吗?
< script type = text / javascript >
function check($ scope){
$ scope.check = function (tableField,input){
if (input.type == 或){
if (tableField.name.indexOf(input.name)> -1 || input.n ame == null || tableField.created_by.indexOf(input.createdby)> -1 || input.createdby == null ){
return true
}
else {
return false
}
}
}
}
< ; / script >
< table ng-table = table >
< tbody >
< tr ng-repeat = 汽车中的汽车 ng-controller = 检查 ng- show = check(car,externalFilters) >
< td data-title = '姓名' >
{{car.name}}
< ; / td >
< td data-title = '由''创建 >
{{car.created_by || 'unknown'}}
< / td >
< / tr >
< / tbody >
< / table >
我的尝试:
我尝试删除input.name == null和input.createdby == null,但它可以工作,但是在加载时不会显示任何数据,因为脚本返回false 。
范围){
scope.check = function (tableField,input){
if (input.type == 或){
if (tableField.name。 indexOf(input.name)> -1 || input.name == null || tableField.created_by.indexOf(input.createdby)> -1 || input.createdby == null ){
return true
}
else {
return false
}
}
}
}
< ; / script >
< table ng-table = table >
< tbody >
< tr ng-repeat = 汽车中的汽车 ng-controller = 检查 ng- show = check(car,externalFilters) >
< td data-title = '姓名' >
{{car.name}}
< ; / td >
< td data-title = '由''创建 >
{{car.created_by || 'unknown'}}
< / td >
< / tr >
< / tbody >
< / table >
我的尝试:
我尝试删除input.name == null和input.createdby == null,但它可以工作,但是在加载时不会显示任何数据,因为脚本返回false
Hi,
I have 2 input field, and I want to filter the table against the 2 input fields using OR instead of And.
However I'm unable to do it with the code below, the table return all field regardless what I type in the input, anyone can help me with it?
<script type="text/javascript">
function checking($scope) {
$scope.check = function(tableField,input) {
if (input.type == "or"){
if (tableField.name.indexOf(input.name) > -1 || input.name == null || tableField.created_by.indexOf(input.createdby) > -1 || input.createdby == null ){
return true
}
else{
return false
}
}
}
}
</script>
<table ng-table="table">
<tbody>
<tr ng-repeat="car in cars" ng-controller="checking" ng-show="check(car,externalFilters)">
<td data-title="'Name'">
{{car.name}}
</td>
<td data-title="'Created by'">
{{ car.created_by || 'unknown' }}
</td>
</tr>
</tbody>
</table>
What I have tried:
I have tried removing input.name == null and input.createdby == null, and it works, however on load no data will be shown, as the script return false.
scope) {
scope.check = function(tableField,input) { if (input.type == "or"){ if (tableField.name.indexOf(input.name) > -1 || input.name == null || tableField.created_by.indexOf(input.createdby) > -1 || input.createdby == null ){ return true } else{ return false } } } } </script> <table ng-table="table"> <tbody> <tr ng-repeat="car in cars" ng-controller="checking" ng-show="check(car,externalFilters)"> <td data-title="'Name'"> {{car.name}} </td> <td data-title="'Created by'"> {{ car.created_by || 'unknown' }} </td> </tr> </tbody> </table>
What I have tried:
I have tried removing input.name == null and input.createdby == null, and it works, however on load no data will be shown, as the script return false.
这篇关于带有多个输入的过滤表,带有“或”操作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!