Data table column filter

2,362 views
Skip to first unread message

Guilherme Gusman

unread,
May 10, 2012, 8:54:04 AM5/10/12
to Google Visualization API
I have a data table the renders the following JSON object:

var v_JSONObject = {
"cols": [
{ "id": "Date", "label": "Date", "type": "datetime" },
{ "id": "Value", "label": "Speed", "type": "number" },
{ "id": "Value", "label": "Pressure", "type": "number" }
],
"rows": [
{ "c": [{ "v": new Date(2010, 2, 2, 1, 0, 0), "f": null },
{ "v": 103, "f": null }, { "v": 53, "f": null}] },
{ "c": [{ "v": new Date(2010, 2, 2, 2, 0, 0), "f": null },
{ "v": 22, "f": null }, { "v": 73, "f": null}] },
{ "c": [{ "v": new Date(2010, 2, 2, 3, 0, 0), "f": null },
{ "v": 234, "f": null }, { "v": 121, "f": null}] },
{ "c": [{ "v": new Date(2010, 2, 2, 4, 0, 0), "f": null },
{ "v": 122, "f": null }, { "v": 12, "f": null}] },
{ "c": [{ "v": new Date(2010, 2, 2, 12, 0, 0), "f":
null }, { "v": 54, "f": null }, { "v": 76, "f": null}] }
]
}

So the first column is fixed, it's the date column and the others not.
I would like to include many columns as i want and filter them... i
know that a can filter for rows content but i would to filter by the
column header content, is that possible?

So in the end my table would be something like this:

Date | Speed | Pressure | RPM | ...
2010/05/05 | 35 | 38 | 454 | ...
2010/05/05 | 5 | 28 | 151 | ...
2010/05/05 | 45 | 12 | 424 | ...
2010/05/05 | 36 | 63 | 472 | ...

I would like to use the "CategoryFilter" to "play" with the columns.
Is that possible?
If not, is there another workaround that i can try?

Thanks in advance,
Guilherme Gusman



asgallant

unread,
May 10, 2012, 10:43:41 AM5/10/12
to google-visua...@googlegroups.com
There aren't any controls in the API for adding or removing columns, but you can build your own.  Attaching event handlers to HTML checkboxes is probably the most common way to do this.  If you like the look of the CategoryFilters, though, I came up with a pretty decent hack to make them work on columns: http://jsfiddle.net/asgallant/WaUu2/ 

Guilherme Gusman

unread,
May 10, 2012, 10:56:10 AM5/10/12
to google-visua...@googlegroups.com
Thank you very much!!

That's exactly what i wanted to do! 

2012/5/10 asgallant <drew_g...@abtassoc.com>
--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/IrjFqRAZERAJ.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Reply all
Reply to author
Forward
0 new messages