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

[Feature Request] Sort function in table header #33

Closed
jehutywong opened this issue Aug 24, 2018 · 20 comments
Closed

[Feature Request] Sort function in table header #33

jehutywong opened this issue Aug 24, 2018 · 20 comments

Comments

@jehutywong
Copy link

It would be nice to support sort in column headers.

@Ye-Tian-Zero
Copy link

May I ask when will sort function be supported? Thanks 😄

@yesoreyeram
Copy link
Owner

I am happy to merge if someone contribute to this. I may some time later this month if no contributions received.

@NivAmat
Copy link

NivAmat commented Feb 26, 2019

I'll also be glad to have this ability.

Thanks for the great plugin!

@Ye-Tian-Zero
Copy link

I never use TypeScript. So it may take too much time for me to implement it. But if I have time, I will try it.

@NivAmat
Copy link

NivAmat commented Feb 27, 2019

hey,
so I tried to implement this, but I encounter 1 major problem - the headers are being generated in runtime, without letting the angular infrastructure build those new html tags, means you can't add "ng-click" to those header tags.

I'm referencing to the file: src\app\app.ts
in lines 81 and 84:
line 81:
output.headers += <th style="padding:4px;text-align:${options.text_alignment_firstcolumn}" ng-click="ctrl.sort()">${default_title_for_rows}</th>;

line 84:
output.headers += <th style="padding:4px;text-align:${options.text_alignment_header}" ng-click="ctrl.sort()">${c}</th>;

so I tried to add ng-click, but the angular doesn't recognize that tag because that new html-tag isn't being built again. though if I'll change it to onclick - it will work, but it won't recognize ctrl object, means I can't use any angular object, which makes it impossible to implement with onclick.

any solution for that?

the rest of the feature I can implement in less than a day

@NivAmat
Copy link

NivAmat commented Mar 7, 2019

@yesoreyeram
I've implemented the sort function, I just need an answer to my question above to be able to send a pull request

Please assist :)

@yesoreyeram
Copy link
Owner

@NivAmat Glad to see you trying to solve this. I feel that ng-click should work. But i haven't tried yet. If that really doesn't work, HTML part can be moved to HTML template. Give a try and let me. I will try once I find time. Thanks BTW.

@yesoreyeram yesoreyeram changed the title sort function in table header [Feature Request] Sort function in table header Mar 7, 2019
yesoreyeram added a commit that referenced this issue Mar 10, 2019
@yesoreyeram
Copy link
Owner

Sorting is enabled in master branch with the following conditions

  • By default values are not sorted
  • If header cells are clicked, table will be sorted by asc / desc
  • Sorting is based on actual values.
  • Sorting is not persisted.
  • Not matching series always goes bottom.

Some examples given below. ( note the arrow in the header )

image
image
image
image

@yesoreyeram yesoreyeram pinned this issue Mar 10, 2019
@yesoreyeram
Copy link
Owner

@NivAmat if you can spend time , could you review my solution and let me know if you see any problems.

@NivAmat
Copy link

NivAmat commented Mar 11, 2019

@yesoreyeram it looks good, but its not possible to also sort by the first column (possible to use a simple string comparator for this situation.. what do you think?)

@JosephFY
Copy link

@yesoreyeram and @NivAmat Thank you for the effort to add this, can't tell you how important this is in our use case. Is there any way to have the Sorting persisted when saving the dashboard? Having this on big display screens and need certain values to be on the top when they change (like down devices will be colored red and will move on the top of the list) hard to go to all screens and change that every time the dashboard reloads or rotate on a playlist

Sorting is not persisted.

@yesoreyeram
Copy link
Owner

@JosephFY that is not a big change to implement. But want to make sure that sorting is working as expected. That needs some testing. We dont want any bugs introduced.

Can you confirm if this works as expected for you?

@Bounzz
Copy link

Bounzz commented Mar 28, 2019

Any news for that pr ?

@NivAmat
Copy link

NivAmat commented Mar 28, 2019

@yesoreyeram We have tested the new feature and it seems to work just great.
The only concern is that it is not possible to sort by the first column (the index column)

@Bounzz
Copy link

Bounzz commented Apr 30, 2019

When this feature will be available ?

@NivAmat
Copy link

NivAmat commented May 2, 2019

@Bounzz I've implemented a fix for the above issue (the first column cannot be sorted).
I'll push it early next week.

@Bounzz
Copy link

Bounzz commented Jun 7, 2019

Any news ?

@yesoreyeram
Copy link
Owner

This feature is already availbale in master branch.

@Bounzz what you are expecing?

@Bounzz
Copy link

Bounzz commented Jun 7, 2019

Sorry im not good with github.

How can i update the plugins ?

@yesoreyeram
Copy link
Owner

bbe0646 should help persistant sorting. Availble in latest master or from version 1.2.x

@yesoreyeram yesoreyeram unpinned this issue Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants