bStateSave creates erroneous sort order

bStateSave creates erroneous sort order

WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
edited May 2012 in Bug reports
Debug code: ijomuc
Version: Nightly 1.9.2.dev - Sun 20th May 2012, 10:33

Example here:
https://beta.propertypreswizard.com/test_scripts/beta/stretch.html

To reproduce:
1. Click a column to sort, e.g. "Client" ascending. Note the order of the items in "Status"
2. Refresh the page, "Status" column is now in a different order. Later refreshes show the same result.
3. To retrigger, sort a different column, then back to "Client", refresh page.

What is going on here? How can I get consistent sorting after refreshing?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi,

    This is an interesting one - basically what is happening here is that the first sort effects the second one. So when the table loads the first time, it is sorted by Status, then it is sorted by Client. However, when the table is then reloaded, it is sorted by Client only, and this results in the difference because of the number of identical items in the client column. Once the sort method has found the right order for the column in question it bails out, not looking at the other columns.

    To get consistent sorting we'd need to sort by the default column first, then apply the saved sort, but this seems very inefficient - particularly with large data sets.

    There is another option with DataTables 1.9 though. You could use aDataSort - this parameter allows you to define multi-column sorting without the user needed to specify the multi-column sort themselves. For example aDataSort: [ 4, 0 ] would sort by your Client column first, then the Status column - giving a consistent sort. It does mean you need to define this definition, but that might be acceptable, given the tradeoffs?

    Great looking table btw! Might you be willing to share some of the styling CSS that you've used? :-)

    Regards,
    Allan
  • WeaponX86WeaponX86 Posts: 40Questions: 0Answers: 0
    edited May 2012
    I might have to do a manual workaround for bStateSave. I'll think on it some more.

    The stylesheet I use is here, all made by me:
    https://beta.propertypreswizard.com/test_scripts/beta/css/default.css (some gradients and font definition here)
    https://beta.propertypreswizard.com/test_scripts/beta/css/datatables.css

    Gradients are pure css, built here:
    http://www.colorzilla.com/gradient-editor/

    Rounded corners built here:
    http://roundedcorner.org/css3-rounded-corner-generator?quicktabs_CSS3-Rounded-Corner=customer#quicktabs-CSS3-Rounded-Corner

    The live version has a text size slider at the bottom that resizes text and columns in realtime, also the grid expands to fill the screen horizontally and vertically which is demonstrated here:
    https://beta.propertypreswizard.com/test_scripts/beta/home.php
This discussion has been closed.