• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 46
  • Last Modified:

csv to html automatic reverse chronological sort

Not sure where to begin, I am using a CSV to Html table template by Derek Eder https://github.com/derekeder/csv-to-html-table.
I'm using it to display a list of events that have happened, I would like to see if there is a way to make the default sort for the java app be reverse chronological order instead of chronological order. I know there are multiple sort functions, however since I am automatically refreshing every 10 seconds and it would be handy to have the results sorted the way I would like automatically.
I don't have any experience in java so any help would be greatly appreciated.
0
csePixelated
Asked:
csePixelated
  • 3
1 Solution
 
CEHJCommented:
Done in 100% JavaScript.
(Not a Java question)
1
 
Chris StanyonCommented:
OK. Firstly, this is Javascript - not Java. They're completely different languages :)

Having a quick peak at the docs, it looks like it's backed up by the DataTable plugin and there is an option to set the plugin settings. The setting for the default sort order in DataTables is :

{ "order": [[ 3, "desc" ]] }

The 3 is the zero-based index of the column you want to sort on.
Just add that to your init script:

<script>
  CsvToHtmlTable.init({
    csv_path: 'yourData.csv', 
    element: 'table-container', 
    allow_download: true,
    csv_options: {separator: ',', delimiter: '"'},
    datatables_options: {"paging": false, "order": [[ 3, "desc" ]] }
  });
</script>

Open in new window

0
 
csePixelatedAuthor Commented:
My apologies, yes Javascript is what i meant, just tried Chris Stanyon comment  adding "order": [[ 3, "desc" ]]  in the database options, now i get no results.
0
 
csePixelatedAuthor Commented:
i had forgotten the comma, it shows data but not in not in reverse chronological order my dates/times look like 2/19/2018 9:29:43 AM that is how i want them. however it's still oldest to newest?
0
 
csePixelatedAuthor Commented:
never mind i was looking at the wrong page, my desktop has too much going on, ty Chris Stanyon
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now