daniel-nagy / md-data-table

Material Design Data Table for Angular Material
MIT License
1.9k stars 520 forks source link

Sorting only current page #553

Closed muscaiu closed 7 years ago

muscaiu commented 7 years ago

I'm trying for hours to figure out why it's only sorting the current page. The same thing is happening on the search filter. Why is it doing this?

<md-table-container>
        <table md-table="" md-progress="promise" ng-model="selected">
            <thead md-head md-order="sort.order">
                <tr md-row>
                    <th md-column md-order-by="dataapplicazione"><span>Data app</span></th>
                    <th md-column md-order-by="nomecognome"><span>Nome e cognome</span></th>
                </tr>
            </thead>
            <tbody md-body>
                <!--<tr md-row md-select="item" md-select-id="name" ng-repeat="item in main.interviewsList |  limitTo: sort.limit : (sort.page -1) * sort.limit  | orderBy:sort.order | filter:searchInterview ">-->
                <tr md-row ng-repeat="item in main.interviewsList |  limitTo: sort.limit : (sort.page -1) * sort.limit  | orderBy:sort.order | filter:searchInterview ">
                    <td md-cell>{{ item.dataapplicazione | date}}</td>
                    <td md-cell>{{ item.nomecognome }}</td>
            </tbody>
        </table>
    </md-table-container>
<md-table-pagination md-limit="sort.limit" md-limit-options="limitOptions" md-page="sort.page" md-total="{{main.interviewsList.length}}" md-on-paginate="promiseInterviews" md-page-select></md-table-pagination>

Sorting Desc 1 Sorting Asc 2

muscaiu commented 7 years ago

The problem was the order of the filters. I changed it to | orderBy | filter | limitTo and it works.