Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting does not take multiple pages into account #26

Open
devotox opened this issue May 18, 2017 · 4 comments
Open

Sorting does not take multiple pages into account #26

devotox opened this issue May 18, 2017 · 4 comments

Comments

@devotox
Copy link

devotox commented May 18, 2017

When you sort by a column it does not look at the other pages ... it just sorts current page.

Is there an action at least we can override to perform our own sorting?

@panthony
Copy link
Contributor

@devotox You can pass onChangeSort on the table itself. Combined with sortProp and sortDir you have full control hover the state and how you sort your data.

See #13

@syedasadhasan
Copy link

I added the onChangeSort handler and change the model data accordingly but sorting is still working on the displayed records only.

@panthony
Copy link
Contributor

panthony commented Feb 8, 2018

@syedasadhasan You can do something like this:

          {{#paper-data-table
            sortProp=model.sortProp
            sortDir=model.sortDir
            onChangeSort=(action "onChangeSort") selectable=false as |table|}}
           {{!-- iterate over model.items !--}}
         {{/paper-data-table}}
onChangeSort({ sortProp, sortDir }) {
    // if all items exists locally you can just sort 'items' instead of querying your backend.
    this.fetchItemsFromByBackend({ sortProp, sortDir }) // fetch items from backend using new sort
         .then((items) => {
           // update items with sorted one from my backend
           this.set('model', { items, sortProp, sortDir });
         }); 
}

@syedasadhasan
Copy link

I tried this and sorting is working only on the column which is set as default to sortProp in template with {{#paper-data-table}}. For any other column, when I clicked to sort, in onChangeSort action i am getting these values. sortDir=undefined and sortProp = {sortProp: "name", sortDir: "asc"}. Now when I click again on same column I got again same value for direction, sortDir=undefined and sortProp = {sortProp: "name", sortDir: "asc"}. Pls help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants