Closed zzjustinzz closed 7 years ago
For md-head there's an attribute: md-on-reorder="getItems"
. Did you try it?
Also delete orderBy
from ng-repeat
.
And isn't it better to use:
<md-table-pagination md-limit="query.limit" md-limit-options="[5, 10, 15, 25]" md-page="query.page" md-total="{{items.count}}" md-on-paginate="getItems" md-page-select></md-table-pagination>
And delete limitTo
from ng-repeat
?
I have tried follow your instruction, but it's not still working. :(
[image: Inline image 1]
I have tried follow your instruction, but it's not still working. :( ᐧ
On Wed, Mar 22, 2017 at 6:52 PM, Arthur notifications@github.com wrote:
Just to provide a working example. Mark-up: [image: 2017-03-22 13_48_10-cphdev7 - remote desktop connection] https://cloud.githubusercontent.com/assets/889454/24196405/5f2c5d32-0f06-11e7-88ba-305f8db638cf.png Code: self.$scope.manufacturers = []; self.$scope.query = { filter: '', limit: 15, order: 'name', page: 1 }; self.$scope.getManufacturers = function () { self.$scope.promise = self.manufacturerService .get(self.$scope.query, function (response) { self.$scope.manufacturers = response.items; self.$scope.manufacturers.count = response.itemsCount; }); };
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/daniel-nagy/md-data-table/issues/565#issuecomment-288376047, or mute the thread https://github.com/notifications/unsubscribe-auth/AEwK9dZNgWqg5nUmPvDHiBI5f_l2AIf3ks5roQuBgaJpZM4Mk8Pi .
Okay, as far as I can see, you load items from the API. At least I see md-progress
usage, which should be used only for that. :)
Let me share a working example. So here's a mark-up:
Here's an initial state inside controller:
Here's a code for getManufacturers
method:
Now, all together. Page 1:
Page 2:
In case you're using pagination on a front-end, then it should be done a bit in another way. :)
Is your Search filter working for the current page only or for the whole data?
My Search filter is working for the whole data, but order is just only current page.
For the whole data.
Dont know why, but it's not work for me:
My HTML:
My controller:
My page:
-Page 2
I see. So you load all the items and try to sort them and paginate? :)
Yep. I load all item first and sort, paging them then.
Okay, I assume that data is not ordered from the beginning thus you have such strange pagination with ordering. Try to order the data right after you received it:
$scope.kaizens = kaizens.result.map(function(k1, k2) {
if (k1.name > k2.name) {
return 1;
}
if (k1.name < k2.name) {
return -1;
}
return 0;
}
;
Or by any other property (e.g. kaizenNumber). In case of kaizenNumber ordering:
$scope.kaizens = kaizens.result.map(function(k1, k2) {
return k1.kaizenNumber - k2.kaizenNumber;
}
;
Or even better: try to put orderBy
filter before limitTo
.
So in your case:
So, as a summary. Return to original mark-up and code and put orderBy
before limitTo
.
And delete md-progress
attribute.
Thanks its worked.
Dont know why my table is order in only one page, not all page.
Anyone can help me :(
My code:
HTML:
Controller: