Closed Sammaye closed 2 months ago
Probably yes.
Before changing anything, what scenarios for this are existing:
1) User is on page 4 with 20 records on the page, he want's to sort after a certain column, so he clicks it, now we have the following options:
So i think to cover both, you need a sort page and a sort total;)
Is there ever a time where the sort remaining on the same page is actually useful? I mean how do you know where you are in the dataset if the sort has now changed?
I hope someone from the core team can answer your question;)
Current page sorting could be useful if page has lots of results but such behavior logically conflicts with overall re-sorting.
@yiisoft/core-developers need more opinions.
I think this is a definite "yes". If you change the sort criteria, it doesn't make sense NOT to update the display to start with page 1. I can't imagine a scenario in which I'm X pages into a view, decide to change the sort criteria, but would still want to be X pages in (under the different criteria).
I agree with returning to the first page after change sorting.
That exceptional usecase seems too far fetch. I support @Sammaye's proposal.
Hmm... any thoughts about how to achieve it w/o Sort
doing Pagination
job?
Changed milestone to 2.1 since it's not critical for 2.0 release.
Cant you just amend the ListView/GridView sorter methods to include custom urls for the sort functions which exclude the page var as defined in the pagination class?
So just add Url handling specifically for the view, i.e. listview within render sorter of: https://github.com/yiisoft/yii2/blob/master/framework/widgets/BaseListView.php
It seems like either way the sorter needs to be aware of the pagination in the case of these widgets and customise its links when uysed in thisn context.
+1. This would come in handy.
@Sammaye you can extend the \yii\data\Sort
class and edit this method. https://github.com/yiisoft/yii2/blob/master/framework/data/Sort.php#L335
what you want would be as simple as adding this line on line 340
unset($params['page'])
assuming that your page attribute is 'page'
staying on the same page (depth) is not really logical, as this is related to another sort criterium. This is room for improvement. @Sammaye, @Faryshta , do you have ideas for a PR?
It's been so long I cannot even remember the file that deals with this, I think it is Pagination.php
or something
Any news on this?
No.
$(document).on('pjax:success', function() {
$('#grid_id th a').attr('href', function(i,data){
return data.replace( /&page=[0-9]/gi, '' );
});
I solve it via jquery
Currently, we can use GridView
method keepPageOnSort()
to configure it. By default page don't keep on sort changing.
I have noticed that I can be on page 3 of ListView but when I change the sort it remains on page 3. Logically you would expect it to return to page 1 since page 3 of a new sort is not very useful to the end user.
Should it be changed to go from page 1 when sort changes?