Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 with paging #2819

Closed
wlodarzmar opened this issue Sep 17, 2015 · 26 comments
Closed

Sorting with paging #2819

wlodarzmar opened this issue Sep 17, 2015 · 26 comments

Comments

@wlodarzmar
Copy link

Hi.
I saw pagination demo: http://docs.handsontable.com/0.18.0/demo-pagination.html and I have added sorting to it, but when I click on header then sorting is applied only for data currently displayed.
Is there a possibility to sort whole data when I use pagination? I need some demo or clue.

@AMBudnik
Copy link
Contributor

Please check our sorting guide at http://docs.handsontable.com/0.18.0/demo-sorting-data.html?_ga=1.165582783.1270603665.1430732719 there are not the exact cases as yours but it can help you
columnSorting indeed works only with data that are in your part

@tompazourek
Copy link

Is there a workaround? Would it be possible to handle the event when column sorting changes and reload the data part through AJAX (including the sorting information in the AJAX request)?

Multiple pages with sorting is a very common use case for many grids. Is it really impossible in Handsontable?

Thanks! :)

@kaitlynreese
Copy link

+1

@jdmcnair
Copy link
Contributor

@AMBudnik this seems like a legitimate issue to me. Sorting appears to be broken when pagination is involved.

@AMBudnik
Copy link
Contributor

I'll reopen this issue for further discussion.

@rhymes
Copy link

rhymes commented Jul 4, 2016

@AMBudnik any updates on this?

@AMBudnik
Copy link
Contributor

AMBudnik commented Jul 4, 2016

@rhymes unfortunately not yet.

This one is pretty tricky as paging is not actually a plugin.

Please stay tuned to this issue for more updates. Additionally you can check our Roadmap: https://trello.com/b/PztR4hpj/handsontable-roadmap-2016-login-to-vote-for-features

@rhymes
Copy link

rhymes commented Jul 4, 2016

@AMBudnik thanks!

@ghost
Copy link

ghost commented Nov 18, 2016

Couldn't we have a setDataMapAtColumn method to call so we populate ourself the list of distinct value of the filter when the pagination is involved ? I am also using a pagination in my table and I am an API call that gives me all the distinct values for a specific column, that could be very handy I think.

But we would need to get a callback event when we open the filter, so we can update the data accordingly.

@hycday
Copy link

hycday commented Dec 28, 2016

@AMBudnik is this still planed or under investigation ? as pagination is very important when one has many data, it breaks the purpose of the script until this is fixed :( thanks for any update !

@AMBudnik
Copy link
Contributor

AMBudnik commented Jan 2, 2017

hi @hycday
I am not sure if we are thinking about the same case. The pagination demo here: https://docs.handsontable.com/pro/1.8.2/demo-paginating.html loads parts of data - not the whole dataset so the sorting will work only for data that is loaded.

@hycday
Copy link

hycday commented Jan 3, 2017

hi @AMBudnik !
Well, what I mean is the following : if the filtering option is added with pagination, filter will only apply to the page on which the user is, which defeats the purpose of pagination, or of filtering.

for example, on the link you just shared, if filtering is added, and user filters column A to filter by value "1", results will only show 4 lines in page 1 (and page 2-3-4-5-etc are wrongly filtered), whereas it should show 18 rows (in 3 pages, since its 6 rows per page).

so is there a way of having the filtering with pagination working like described above, i.e. on all data, and not only the page displayed.
thanks for your answer !

@AMBudnik
Copy link
Contributor

AMBudnik commented Jan 4, 2017

With the current pagination demo structure there is no way to display result of filtering or sorting for whole data set. You will always get a result for a single page. You would need to perform sorting or filtering server side and on the whole data set to get this working.

@ghost
Copy link

ghost commented Jan 4, 2017

I completely agree with @hycday.
@AMBudnik I already have all the distinct value of my table beforehand, it would be very smart to add a function to populate the sorting by value ourselves. Because at the moment there is no way to do so. And I don't want to load the whole dataset from a table that has 2M rows.. (which is where the sorting is very important)

If we could have a method to override how the sorting by value works, it would fix the issue.

@dtslvr
Copy link

dtslvr commented Jan 4, 2017

Indeed, a method to override the sorting function where i can do my REST call with the sorting parameters would also fix my issue.

@BhanuKrishnaKaturi
Copy link

I am also in need of what @marc-antoinepelletier has been asking for. Is there any workaround to populate the filter dropdowns with our own values? If there is a function which can accept a datasource to re-populate the filter values in the dropdown when the pagination is involved that would be great. I need the filter menus to get their values populated from the whole dataset but not from only the current page dataset values. Please get back with an API or event that I can make use of.

@dtslvr
Copy link

dtslvr commented Jan 5, 2017

I found the event beforeColumnSort which is exactly what I'm looking for. There I build the url for the REST call with sorting parameters and reload the data. I hope that helps anyone of you, too.

@AMBudnik
Copy link
Contributor

AMBudnik commented Jan 5, 2017

@dtslvr
that is correct, please check the demo http://jsfiddle.net/ygp7xaa0/

@hycday
Copy link

hycday commented Jan 5, 2017

well this is exactly the issue that I am trying to point : in your jsfiddle, if on column A, you filter by value "1", the table displays 4 rows on page 1, but then shows 4 rows with value 0 on page 2 etc...so filtering is not correct with pagination.

whereas it should :
either show 4 rows on page 1, 2 rows with value 1 on column A on page 2, then 4 on page 3, then 2 again etc...
OR
it should show 3 pages in total, with 6 rows each with column A value 1 per page (since total number of rows with column A value 1 is 18).

and let's say for example that one of the rows on page 4, column A has value "3", then filtering should also show "3" as an option of filtering, even if we are on page 1.

@AMBudnik
Copy link
Contributor

AMBudnik commented Jan 5, 2017

@hycday
I do understand. This demo only logs the tips to connect it with back end sorting it does not trigger server side sorting.

@ghost
Copy link

ghost commented Jan 5, 2017

@AMBudnik The filtering is a plugin (https://docs.handsontable.com/pro/1.8.2/demo-filtering.html) as far as I could see, but then it's in the pro version, is there a way to look at the source anyhow ? to be able to override part of the code to make it work for our need ?

I've done that with the undoRedo plugin using this link http://docs.handsontable.com/0.29.2/plugins_undoRedo_undoRedo.js.html, I was able to change some behaviour of a specific method to make it work for me.

Any chance we can do the same with the filtering ? so we can override it ?

@AMBudnik
Copy link
Contributor

AMBudnik commented Jan 5, 2017

Hi @marc-antoinepelletier
If you would like to build anything on a part of Handsontable PRO plugin you would need to own a commercial license. You can easily see the code (for example via trial version) but using even a part of it without the license is forbidden.

@AMBudnik
Copy link
Contributor

Thank you very much for all the propositions and opinions. I am moving this feature request to our wiki section > feature requests.

@Sheetal1289
Copy link

Hi @AMBudnik

Any Updates on this topic. I need this feature like when user will sort the data, then sorting should work on all page. For example, Suppose if I sort data "empcode " on my page the first page contain data like 1,2,3 records and on the 2nd-page 4,5,6 records are present. when user will sort the at that time the last record i.e empcode 6 should come on the first page and empcode 1 should go on the last page. Is this possible?

@AMBudnik
Copy link
Contributor

Hey @Sheetal1289 if you do not have many rows of data (of heavy condition logic) you can use hiddenRows to make the table look like paginated. Can you share with me more details? If so please send me an email support@handsontable.com

@AMBudnik
Copy link
Contributor

Hi. Closed issues rarely get new comments, so I hope that this issue will get more attention as a discussion.

See you there for updates and new ideas.

@handsontable handsontable locked and limited conversation to collaborators Apr 30, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

10 participants