Giter VIP home page Giter VIP logo

Comments (4)

panthony avatar panthony commented on June 30, 2024 1

@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

from paper-data-table.

syedasadhasan avatar syedasadhasan commented on June 30, 2024

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

from paper-data-table.

panthony avatar panthony commented on June 30, 2024

@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 });
         }); 
}

from paper-data-table.

syedasadhasan avatar syedasadhasan commented on June 30, 2024

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.

from paper-data-table.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.