I was working on a similar solution to this and you beat me to posting it 
 >;o)

The only thing I would be concerned about is using:

for (var idx in selection) 

as selection is an array, and that will iterate over *all* of the 
properties of an array, not just it's elements.  Safer to use:

for (var idx = 0; idx < selection.length; idx++)

You can also use the #forEach method of arrays if you don't care about 
compatibility with IE 8 and earlier.

On Monday, May 21, 2012 3:46:01 PM UTC-4, clayadavis wrote:
>
> I ended up getting the behavior I wanted with the following code. 
> Please let me know if there's something wrong/evil/foolish here: 
>
>     var selectedRows = new Array(); 
>     function myTableClickHandler(){ 
>         var selection = tableviz.getSelection(); 
>         for (var idx in selection){ 
>             var item = selection[idx]; 
>             if (item) { 
>                 i = selectedRows.indexOf(item.row); 
>                 if (i == -1){ 
>                     selectedRows.push(item.row); 
>                     tableView.setProperty(item.row, 
> 0,'style','background-color:#d6e9f8;'); 
>                     tableView.setProperty(item.row, 
> 1,'style','background-color:#d6e9f8;'); 
>                 } else { 
>                     selectedRows.splice(i,1); 
>                     tableView.setProperty(item.row,0,'style',null); 
>                     tableView.setProperty(item.row,1,'style',null); 
>                 } 
>             } 
>         } 
>         tableViz.setSelection(null); 
>         tableViz.draw(tableView, tableOptions); 
>         pieView.setRows(selectedRows); 
>         pieViz.draw(pieView); 
>     }

-- 
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/-/8cZrRvwvGWMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to