jhlu87
jhlu87

Reputation: 4019

Javascript google visualization api table undo sort

I have a google visualization Table

https://developers.google.com/chart/interactive/docs/gallery/table

When a user clicks on the column headers it sorts based on that column. Is there a way to undo that sort and revert to the original order of the data? To be clear, I want to be able to sort, but I also want to be able to click somewhere and get the original order back. Is this possible?

Upvotes: 0

Views: 124

Answers (1)

asgallant
asgallant

Reputation: 26340

Just redraw your Table to reset the sort order:

function redrawTable () {
    myTable.draw(data, options);
}
var btn = document.querySelector('#reset');
if (document.addEventListener) {
    btn.addEventListener('click', redrawTable);
}
else {
    btn.attachEvent('onclick', redrawTable);
}

Upvotes: 1

Related Questions