Sorting tables in reverse order

Sorting tables in reverse order

ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
edited February 2014 in General
Hi!
You can see my example here:
http://americantipster.com/?page_id=43

What I would like is the tables to show up on the vertical reverse order, I mean 5, 4, 3, 2, 1 ... and when I add a 6 it should be on top, and the same when I add a 7, and on and on...

What do I have to change?

Thanks in advance!
Isma

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Use assorting to specify the initial sort applied to the table: http://datatables.net/ref#aaSorting

    Allan
  • ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
    I know just a little about coding. Could you tell me where do I have to add the code (I a working on WordPress last version)?
    And if you could tell me the code to show the whole table the [asc] order would be awesome!
    Thanks!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You'd do it just like the example in the documentation. Use `[[ 0, 'desc' ]]` as the array value for aaSorting and you'd add that option into the code where you initialise the DataTable.

    Allan
  • ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
    This is my table:
    https://www.dropbox.com/s/20qdghipjad027t/table.png

    And this the code I added:
    https://www.dropbox.com/s/wvcnh64i44a1ufk/code.png

    But it doesn't sort in reverse order.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Are you not getting a JS error on your console?

    1. What is `A` ? It should be a column index like the documentation says
    2. Why is there a closing brace? Does whatever plug-in you are using need that?

    Allan
  • ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
    No error at all. Take a look at http://americantipster.com/?page_id=43

    1. A is the column I want to lead the sorting. Which one is the column index I should use?
    2. I took off the brace and didn't work either. The plugin I am using is TablePress.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Looks like an error to me:

    > ReferenceError: Can't find variable: A

    Replace it with a 0 - i.e. the column index.
  • ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
    Done,
    http://awesomescreenshot.com/0bb2cqoy90
    but still looking the same.
  • ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
    Allan, I don't mind giving you an admin access if you want to try.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hum:

    > "bSort":false

    But you want a sort?! :-)
  • ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
    I want the table to be ruled by the content on the column A (1,2,3,4,5,...)
    To be shown as ...,5,4,3,2,1
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Okay - so you want to sort on column index 0, as I have said, But you have specifically disabled sorting, so obviously sorting is not going to occur.

    Allan
  • ismamartinezismamartinez Posts: 8Questions: 0Answers: 0
    I enabled sorting and used 0 as column index and doesn't works.
    http://awesomescreenshot.com/0422ctcl1b
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Why aren't you asking TablePress about this?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You are using a 1D array. I specifically gave you a 2D array, and the documentation clearly states that aaSorting uses a 2D array. Please see my comment above and read the documentation.
This discussion has been closed.