SELECT a.ID,
a.col1,
a.Col2,
a.Col3,
b1.Col_X
FROM (
SELECT a_id
,max(rank) AS MaxRank
FROM tableb
GROUP BY a_id
) b
INNER JOIN tablea a ON a.id = b.a_id
INNER JOIN tableb b1 ON b.a_id = b1.a_id AND b1.rank = b.MaxRank
ORDER BY a.ID;
和我的HTML
controllers.js
listingControllers.controller('todoCtrl', function($scope, $http) {
$scope.filteredTodos = [];
$scope.itemsPerPage = 10;
$scope.currentPage = 1;
$scope.makeTodos = function() {
$http.get('properties/master.json')
.then(function(res){
$scope.todos = res.data;
$scope.figureOutTodosToDisplay();
});
};
$scope.figureOutTodosToDisplay = function() {
var begin = (($scope.currentPage - 1) * $scope.itemsPerPage);
var end = begin + $scope.itemsPerPage;
$scope.filteredTodos = $scope.todos.slice(begin, end);
};
$scope.makeTodos();
$scope.pageChanged = function() {
$scope.figureOutTodosToDisplay();
};
$scope.$watch('search.renttype', function(term) {
console.log('filter by ' + term);
$scope.makeTodos();
var temp = $scope.todos;
$scope.filteredTodos = [];
// Create $scope.filtered and then calculat $scope.noOfPages, no racing!
$scope.todos = [];
//console.log('filtered list?? ' + JSON.stringify(bob));
$scope.todos = $.grep(temp, function(e){
return e.xsitype == term;
});
$scope.pageChanged();
});
});
我确定我犯了一个愚蠢的错误,我们正在使用bootstrap ui进行分页
答案 0 :(得分:0)
我实际想出了这个,这就是我得到的
listingControllers.controller('todoCtrl', function ($scope, $http, $filter) {
$scope.todos = [];
$scope.filteredtodos = [];
$scope.currentPage = 1;
$scope.totallistings = 0;
$scope.pageSize = 10;
$scope.maxSize = 10;
$scope.lastfilter = null;
$scope.makeTodos = function() {
$http.get('properties/master.json',{cache:true}).then(function(res){
$scope.filteredtodos = null;
$scope.filteredtodos = res.data;
$scope.todos = res.data;
//console.log('make todos');
});
};
$scope.makeTodos();
//console.log('totalpages '+Math.ceil($scope.filteredtodos.length/$scope.pageSize)+'');
$scope.totalPages = Math.ceil($scope.filteredtodos.length/$scope.pageSize);
$scope.totallistings = $scope.filteredtodos.length;
$scope.$watch('search.renttype', function (newCityName) {
$scope.currentPage = 1;
if( typeof newCityName == "undefined" )
{
$scope.filteredtodos = null;
$scope.filteredtodos = $scope.todos;
}
//console.log('last f+ '+$scope.lastfilter+' - '+newCityName+'');
if ($scope.lastfilter != null && newCityName != $scope.lastfilter)
{
//console.log('filtercomp '+$scope.lastfilter+' - '+newCityName+'');
$scope.filteredtodos = null;
$scope.filteredtodos = $scope.todos;
}
$scope.lastfilter = newCityName;
//console.log('filtere '+newCityName+' active');
$scope.filteredtodos = $filter('filter')($scope.filteredtodos, {xsitype : newCityName});
$scope.totallistings = $scope.filteredtodos.length;
//console.log('totalpages filter '+Math.ceil($scope.filteredtodos.length/$scope.pageSize)+' tlist '+$scope.totallistings);
$scope.totalPages = Math.ceil($scope.filteredtodos.length/$scope.pageSize);
});
});