Custom sorting function in google chart table

I need a google charts table with custom sort for one of the columns. I created a table sorted by: 'event, I think this should emit some kind of event that can be captured, but didn't find any information about it.

+3


source to share


1 answer


Capture the sort event with an event handler:



// table is your Table visualization
google.visualization.events.addListener(table, 'sort', function (e) {
    // e.column is the column to sort
    // e.ascending is a boolean, true for ascending sort, false for descending sort

    // sort your data

    // if you want the ascending/descending elements to work correctly, you need to specify the Table sortColumn and sortAscending options when you redraw the Table, eg:
    options.sortColumn = e.column;
    options.sortAscending = e.ascending;
    table.draw(sortedData, options);
});

      

+1


source







All Articles