Problems Sort, Length

Problems Sort, Length

japaphrjapaphr Posts: 6Questions: 0Answers: 0
edited August 2009 in Bug reports
Hi,
I don't know if anyone has the same problem, but,
1- when you use filter and sort a column, after the sort the list return to page 1. Without the filter after the sort stays in the right active page.

2 - When you use Length, if you are not in the first page, and change the length rows from 10 to 20 for example, always lower length to higher , then the button next doesn't work(using paginate full members) and the rows order are wrong.

Thanks ....

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Hi japaphr,

    1. This is by design. The reason for it is that if you sort, then generally you would expect to go to the start of the sort, rather than some random point in the middle. You can get around this by using fnDisplayRow() and saving the display point just before the click: http://datatables.net/forums/comments.php?DiscussionID=391 - this thread is relevant, but as I say, this is a 'feature, not a bug' ;-)

    2. Interesting - seems to work for me on this example: http://datatables.net/examples/example_alt_pagination.html - does it also work in your browser?

    Thanks,
    Allan
  • japaphrjapaphr Posts: 6Questions: 0Answers: 0
    Hi Allan

    1 - Thanks, I it's clear ...

    2 - Hum, Well, Try these:
    - Go to page 2, check the first row, change length to 25, after the change the first row remains, is this right?
    - The sort returns to first page, OK ... If you press next it works and go to page 2, but if you press next again it does not work, Thanks ...
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Hi japaphr,

    2. Interesting - thanks for point that out. One of your two points is most certainly a bug, I'm just not sure which one :-).

    2.1 - this was my intention - when you change the length then the first record on display should stay there I think.
    2.2. - but that messes up the nicely grouped pages as seen here. What is happening is that the update function isn't realising that the paging has gone slightly out of sync with the buttons due to what has happened above.

    So either
    - Changing the length should jump the start point to a page starting point for that length
    - The update function must take this kind of behaviour into account.

    I'm inclined to go with the second one (although the logic for it might be non-trivial :-) ). Does that sound reasonable?

    Thanks,
    Allan
  • japaphrjapaphr Posts: 6Questions: 0Answers: 0
    Well, I think that your suggestion is reasonable, if you have any simple idea to resolve it or if you will release it in the next version, I'll appreciate ... Thanks Allan ....
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Hi japaphr,

    Okay here we go:

    [code]
    var iPages = Math.ceil((oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength) + 1;
    var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
    [/code]

    If you replace the current iPages and iCurrentPage in fnUpdate for "full_numbers" paging, this will fix the bug that you noted. This will be included in the next release.

    Regards,
    Allan
  • japaphrjapaphr Posts: 6Questions: 0Answers: 0
    Hi Allan,
    It works well !!!
    Last thing, I know that it's not in the right section but it's pertinant to the item 2, I'm trying to make after the change of numbers of rows to paginate, that the list goes to page 1 and doesn't try to keep the first row before the change in first position, but I only succeed in making it go do first page ... Where I must change to make the sort be reloaded without keeping this first row??

    Thanks ...
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Hi japaphr,

    I'm afraid I'm a little confused as to what you are trying to do. Could you explain it again please (sorry - I think I might be having a brain freeze!).

    Allan
  • japaphrjapaphr Posts: 6Questions: 0Answers: 0
    hEheh Sorry, My english can be a little confuse ...

    Currently after you change the rows number, it calculates the page to be displayed and the first row is the one that was there before

    Well, I'm trying to change the behavior of the displaylength,
    When the number of rows is changed, I'd like that it goes to the first page, and the rows be draw according to this new rows display ...

    I think this is more clear eheheh,

    Thanks ...
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    So what you want to do is that when the length of the display is changed, it will always jump to this first page? To do this you can insert "oSettings._iDisplayStart = 0;" into the 'change' event handler for the function _fnFeatureHtmlLength.

    Does this help?

    Allan
  • japaphrjapaphr Posts: 6Questions: 0Answers: 0
    Thanks a lot !! I payed more attention in the source and it worked !!! I was setting 1 instead 0 ... that's why the records were messed up ...

    Nice work with this excellent source !! ..
This discussion has been closed.