Table: code to filter on column header?

370 views
Skip to first unread message

Humble Beginnings

unread,
Apr 20, 2012, 8:50:40 AM4/20/12
to Google Visualization API
Could someone show me the code to put a filter on the first row of the
column table. In Google spreadsheet Gadget I can tag the option on/off
for 'Show Filter'...but I am unable to find the code:


function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Name', 'Height', 'Smokes'],
['Tong Ning mu', 174, true],
['Huang Ang fa', 523, false],
['Teng nu', 86, true]
]);

// Create and draw the visualization.
visualization = new
google.visualization.Table(document.getElementById('table'));
visualization.draw(data, null);
}

asgallant

unread,
Apr 20, 2012, 9:30:13 AM4/20/12
to google-visua...@googlegroups.com

Humble Beginnings

unread,
Apr 20, 2012, 10:39:15 AM4/20/12
to Google Visualization API
No, the best I can describe it is a drop down filter on each column
header.
When I generate a table with the chartwrapper, the first row becomes
the column header and you can order it alphabetically or by ascending
or descending numbers by clicking on the header. What I would like is
a drop down filter which allows you to select a either a specific
name or the number in each column.

The table gadget in Google charts give the filter option...

asgallant

unread,
Apr 20, 2012, 11:20:56 AM4/20/12
to google-visua...@googlegroups.com
Ahh, I see.  The API does not support this out of the box, but you could write javascript to do it.  Hmmm...

Maybe hijack the 'sort' event (set the 'sort' option to 'event', which throws the event but leaves it up to the designer to do the sorting), and create a 'sort' event listener.  In the listener, spawn a dropdown with the options, attach a listener to the dropdown to get the selection, and redraw the table with the selected filter.

gavin

unread,
Mar 27, 2013, 1:53:43 PM3/27/13
to google-visua...@googlegroups.com
you ever figure this out? im looking for the same solution

thx
Reply all
Reply to author
Forward
0 new messages