我有一个按列搜索的数据表,但我只能根据第一页中的结果进行过滤。
如何根据查询的所有结果进行过滤?
有可能吗?
我已经编辑了帖子,我已经包含了视图和控制器的所有代码。
我需要按列搜索,但在所有查询中,不仅仅是在数据表的第一页中。
我正在使用md-data-table模块。
HTML视图
<md-card>
<md-content layout="column" flex>
<md-table-container>
<table md-table>
<thead md-head md-order="query.order">
<tr md-row>
<th md-column ng-repeat="column in autocolumn" md-order-by="{{column.name}}">
<span>{{column.display}}</span>
</th>
</tr>
</thead>
<tbody md-body>
<tr class="buscador">
<td md-cell><input name="NumeroPoliza" ng-model="search.NumeroPoliza" placeholder=" Contrato"></td>
<td md-cell><input name="FechaFactura" ng-model="search.FechaFactura" placeholder=" Fecha"></td>
</tr>
<tr md-row md-select="row" md-auto-select="true" ng-repeat="factura in facturas | orderBy: query.order | limitTo: query.limit : (query.page -1) * query.limit | filter:search">
<td md-cell>{{factura.NumeroPoliza}}</td>
<td md-cell>{{factura.FechaFactura | date:'dd/MM/yyyy'}}</td>
</tr>
</tbody>
</table>
</md-table-container>
<md-table-pagination md-limit="query.limit" md-limit-options="limitOptions" md-page="query.page" md-total="{{datatable.count}}" md-page-select="options.pageSelect"></md-table-pagination>
</md-content>
</md-card>
CONTROLLER
app.controller('ControllerCtrl', ['$scope', '$http', 'CompartirDatos', function($scope, $http, CompartirDatos) {
'use strict';
$http.get('php/qwerty.php').success(function(data) {
$scope.facturas = data;
var original = {
"count": data.length,
"data": data
};
$scope.datatable = angular.copy(original);
$scope.smart = true;
});
//multisearch
$scope.autocolumn = [{
name: "NumeroPoliza",
display: "Contrato"
}, {
name: "FechaFactura",
display: "Fecha"
}];
$scope.multisearch = Array();
$scope.multisearch[0] = {
id: 0,
column: "",
ident: "",
};
//Configure Table
$scope.limitOptions = [5, 10, 15, 50];
$scope.options = {
pageSelect: true
};
$scope.query = {
order: 'name',
limit: 8,
page: 1
};
}]);
SCRIPT PHP
$ruta_sevidor_bd = "1.1.1.1";
$usuario_bd = "user";
$contrasena_bd = "pass";
$nombre_bd = "bbdd";
$conn = mysqli_connect($ruta_sevidor_bd, $usuario_bd, $contrasena_bd, $nombre_bd);
if(!$conn){
die("Connection failed: " .mysqli_connecet_error());
}
$showData = "SELECT * FROM table ";
$data = array();
$result = mysqli_query($conn, $showData);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$data[] = $row;
}
} else {
echo "0 results";
};
print json_encode($data);
mysqli_close($conn);
echo($outp);