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

Correct way to get Rank #70

Open
kkcodes opened this issue Oct 3, 2018 · 1 comment
Open

Correct way to get Rank #70

kkcodes opened this issue Oct 3, 2018 · 1 comment

Comments

@kkcodes
Copy link

kkcodes commented Oct 3, 2018

Hi,

I want to get the rank for each user based on points. This is what I have followed:

http://live.datatables.net/bexupefa/1/edit

And it works fine, but when I perform the search, the ranking goes wrong, because the search result returns a certain set of the result and based on that the new ranking is generated.

I do have a custom query with me, that is calculating the rank, but I am not sure, how to use that with this plugin.

Any guidance is appreciated!

@ypnos-web
Copy link
Owner

ypnos-web commented Oct 3, 2018

Yes, if you use server-side processing you will also need to compute the rank on the server.

  1. Write a custom finder in your Table class, e.g. findWithRank(…) that includes an extra field (e.g. by using your custom query as a subquery)
  2. In controller, provide the name of your custom finder as an argument to the component's find()
  3. Configure the field as with any other field as a dt column

If the rank is independent from the request, you might also want to look into making it a virtual property of your Entity class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants