Git Product home page Git Product logo

Comments (4)

congweibai avatar congweibai commented on August 21, 2024 1

Impressive @benwinding! I like the changes and it works well.

Thanks a lot.

from ngx-auto-table.

benwinding avatar benwinding commented on August 21, 2024

Hi Wyatt 👋
Not sure exactly what you are asking here?
The data$ field must be an Observable right? So that code isn't valid.
You can use filtering on the table already, by using the following configuration:

config = {
  data$: people$,
  // Initially sort by the "name" column
  initialSort: 'name';
  // Initially sort in Descending order
  initialSortDir: "desc";
};

(updated docs to also show this) Is that what you were after? 🙏
Cheers,
Ben

from ngx-auto-table.

congweibai avatar congweibai commented on August 21, 2024

Thanks for your reply.
I understand data$ field must be an Observable. I just try to put code simply but it makes you confused.

Similar example:

const people$ = of([
    {
        name: 'Wyatt',
        tag: {
          id: '001',
          position: 'developer'
      }
    },
    {
        name: 'Ben',
        tag: {
            id: '002',
            position: 'Senior developer'
        }
    },
])
config = {
  data$: people$,
  // Initially sort by the "name" column
  initialSort: 'tag'; // can we sort by 'tag.id' or 'tag.position'?
  // Initially sort in Descending order
  initialSortDir: "desc";
};

I am looking for if is possible to sort items by object key like 'tag.id' numerically or '' tag.postion' alphabetically in the example?

Thanks
Wyatt

from ngx-auto-table.

benwinding avatar benwinding commented on August 21, 2024

All good, yes I was a little confused 😅

I am looking for if is possible to sort items by object key like 'tag.id' numerically or '' tag.postion' alphabetically in the example?

I see now, you're right that wasn't possible but I've just released a small update which allows that! 🎉

You use it just like you said:

    <ngx-auto-table
      [config]="config"
      [columnDefinitions]="{
        name: {},
        'tag.id': {},
         ^ add sub field path here
      }"
    ></ngx-auto-table>
config = {
  data$: people$,
  initialSort: 'tag.id';
    ^ add matching path here too
};

Let me know if there's any issues! 👌

from ngx-auto-table.

Related Issues (6)

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.