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 on multiple tables in same page #66

Closed
SrideviYerneni opened this issue May 4, 2018 · 7 comments
Closed

Sorting on multiple tables in same page #66

SrideviYerneni opened this issue May 4, 2018 · 7 comments
Labels

Comments

@SrideviYerneni
Copy link

I would like to have sorting on multiple tables which are in same page. I tried to follow this documentation. When I'm sorting the table 1, table 2 is also getting sorted.How do I implement this on multiple tables separately. ?

order: any; reverse: boolean = false; setOrder(value: string) { if (this.order === value) { console.log(this.order) this.reverse = !this.reverse; } this.order = value; }

Table 1 :

Name Age
{{Data.name}} {{Data.age}}

Table 2 :

Id Sport
{{PersonData.id}} {{PersonData.sport}}
@VadimDez
Copy link
Owner

VadimDez commented May 4, 2018

Can you provide more code?

@SrideviYerneni
Copy link
Author

SrideviYerneni commented May 4, 2018

 <thead>
              <tr>
                <th (click)="setOrder('Data.name')">Name</th>
                <th (click)="setOrder('Data.age')">Age</th>
              </tr>
            </thead>

Which particular part of code are you looking for?

@VadimDez
Copy link
Owner

VadimDez commented May 4, 2018

To help you i need to see how you're sorting both tables. Provide code for both tables (html) and the part where you set order for both collections as well (ts).

@SrideviYerneni
Copy link
Author

SrideviYerneni commented May 4, 2018

 <table>
                <thead>
                  <tr>
                    <th (click)="setOrder('Data.name')">Name</th>
                    <th (click)="setOrder('Data.age')">Age</th>
                  </tr>
                </thead>
                <tbody>
                  <tr *ngFor="let Data of collection1 | orderBy: order:reverse:'case-insensitive'">
                    <td class="text-truncate">{{Data.name}}</td>
                    <td class="text-truncate">{{Data.age}}</td>
                  </tr>
                </tbody>
              </table>
 <table>
                <thead>
                  <tr>
                    <th (click)="setOrder('PersonData.id')">Id</th>
                    <th (click)="setOrder('PersonData.sport')">Sport</th>
                  </tr>
                </thead>
                <tbody>
                  <tr *ngFor="let PersonData of collection2 | orderBy: order:reverse:'case-insensitive'">
                    <td class="text-truncate">{{PersonData.id}}</td>
                    <td class="text-truncate">{{PersonData.sport}}</td>
                  </tr>
                </tbody>
              </table>

setOrder(value: string) { if (this.order === value) { console.log(this.order) this.reverse = !this.reverse; } this.order = value; }

@SrideviYerneni
Copy link
Author

@VadimDez Hi. Is there any update on this ? Please let me know if you need anything more information.

@mauriciogracia
Copy link

mauriciogracia commented May 2, 2019

In my case I have to ng-fors that are not nested but they share the same sorting options and settings

Here you can see my case with code and with my "solution" which is not ideal

https://stackoverflow.com/questions/55927690/sort-pipe-is-always-sorting-casesensitive-ngx-order-pipe/55957416#55957416

@stale
Copy link

stale bot commented Jul 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 31, 2020
@stale stale bot closed this as completed Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants