Maxl94 / ngx-multi-sort-table

MIT License
40 stars 20 forks source link

Inital arrows #34

Open pgeza opened 3 years ago

pgeza commented 3 years ago

Hi!

I couldn't achieve that on init the table the arrows are shown for the appropriate directions. Only the numbers are shown. Do you have an example for that?

Maxl94 commented 3 years ago

Hi,

you can try rerendering the arrows. Therefor use the updateSortheaders methods of your TableData object. Hop this helps.

yanlobianchi commented 3 years ago

I'm running in the same problem and the updateSortheaders doesn't solve this. I found this solution in stackoverflow https://stackoverflow.com/a/60413444/8222852, but unfortunately this don't respect the direction and stays always in 'asc' direction.

yanlobianchi commented 3 years ago

With a little bit more of searching and tries, I solve that using the css in the stackoverflow's answer of my previous comment and with the following code after the sort event: this.tableData.sortParams.forEach((sortParam, index) => this.sort.sortChange.emit({active: sortParam, direction: this.tableData.sortDirs[index]}) );

I think this should be in the onSortEvent function of the TableData, but its debatable.

Maxl94 commented 3 years ago

Could please share your code? And maybe also a setup to reproduce the initial issue? Thanks

Maxl94 commented 3 years ago

Since there was no activity on this issue, I will close it now

Zackysh commented 2 months ago

Hello! I've encountered a similar issue where the sort arrows' opacity is initially set to zero, even when the header is sorted. This occurs inconsistently (though it always happens in slightly different ways).

Steps to reproduce:

  1. My setup differs from the demo, and I haven’t pinpointed the exact cause of this behavior yet. It might be related to asynchronous data initialization.
  2. When loading the page containing the table for the first time, the arrow always renders correctly—no need for extra setup or calling updateSortHeaders.
  3. Upon reloading the page or navigating to a different app route and back, the arrow often disappears. Occasionally, it renders correctly, but after one or two more reloads, it disappears again.

I've observed that when the arrow renders correctly, the header's _getArrowViewState() returns 'active', but when it doesn't, the return value is 'asc'. Emitting a sortChange event in ngAfterViewInit (as @yanlobianchi suggested) resolves the issue, although it seems to be a workaround.

If any maintainer is interested in reopening this issue, I can provide a (MRE).

Zackysh commented 2 months ago

As you have reopened the issue, I will try to setup a MRE soon.

Zackysh commented 3 weeks ago

If someone else encounter this issue, feel free to aslo upload an MRE. The problem (either on the lib or on my project/s) is quite elusive, I'm working on the MRE from time to time, I hope to find the issue in the next 2-3 weeks.