sorting - How to set first click sort to descending in google charts table -


I have a Google chart table full of data just when a user tries to solve the table (top of any column Clicking on) data is being sorted ascending, and the second click changes the data again, this time descending I want to reverse this behavior, and on a descending sort on a 'no-pre-sorted' column Want to click for the first time, and the second ascending order Click.

For example, in this http: //jsfiddle.net/wrebr0ze/ first click on "Pay" header, $ 12,500 will appear at the top. First click on the "Name" header, the mic should appear at the top.

I tried to look at the sorted event, but although I can hold it, I do not want to sort the data myself, just want to make it the right action trigger I have an API But with no fate, is sorted only works for the initial type (before the data show), not later.

Unfortunately this behavior is not an easy way to reverse. However, here is a workaround using sort events:

  var sorting = {}; Function drawTable () {// ... code var table = new google.visualization.Table (document.getElementById ('table_div')); Google.visualization.events.addListener (table, 'sort', function (e) {if sorting hasOwnProperty ('column')) {sorting = e;} if (sorting.column == e.column) {sorting .desc = sorting.ascending; sorting.ascending =! Sorting.ascending;} other {sorting.desc = true; sorting.ascending = false; sorting.column = e.column;} data.sort ([sorting]); table Draw (data, {showRowNumber: true}}}}) table.draw (data, {showRowNumber: true, sortAscending: false});  

Full Bella:


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -