Open sumit-khajanchi opened 7 years ago
I think what you need is to just change in your controller from :
$scope.query = { order: 'name', limit: 5, page: 1 };
To:
$scope.query = { order: '-name', limit: 5, page: 1 };
Note the "-" in name to make descending
Hello Sir,
Actually i fired query in $http
get request to fetch results but when i use order: -name
wrong results fetched and when i used order: name DESC
correct results were fetched but the sorting up/down direction arrow in data-table were not changing.
You'll want to use mdOnReorder
to update your $http
request. Let the table use name
and -name
so it knows the sort direction and just map the values to name ASC
and name DESC
.
A bit late but anyway. I've set up the following method in my controller (this.order
being what is changed by md-order
and this.query
from where the database query is built):
this.onReorder = () => {
let m = this.order.match(/(-?)(.*)/);
let attr = m[2];
let direction = m[1] ? 'DESC' : 'ASC';
this.query.order = `${attr} ${direction}`;
this.refresh();
};
Hi, I have to change the value of
query.order
from"name" to "name ASC"
or"-name" to "name DESC"
. What should i do, please help me to resolve this problem.