Yes, you can deselect an element in code.  The #setSelection method takes 
an array of objects with "row" and/or "column" properties that identify the 
element(s) selected.  Remove the element you want to deselect from the 
array and pass the array back to #setSelection.  To deselect all elements, 
you can call #setSelection without passing any parameters.

On Saturday, January 26, 2013 7:02:06 AM UTC-5, [email protected] wrote:
>
> Can I deselect an element manually in code without requiring another click?
> Because currently, the solution you offered requires 2 clicks on the same 
> element when the first (deselect) does nothing and the 2nd one is the 
> select one.
>
> On Sunday, January 20, 2013 7:20:47 PM UTC+2, asgallant wrote:
>>
>> If you click on a selected element, it deselects that element, but the 
>> "select" event is still fired.  You can test to see if anything is selected 
>> by checking the length of the array returned by 
>> table.getChart().getSelection():
>>
>> google.visualization.events.addListener(table, 'select', function () {
>>   var sel = table.getChart().getSelection();
>>   if (sel.length > 0) {
>>     var tmpData = table.getDataTable();
>>     var msgArray = ['You have selected:'];
>>     for (var i = 0; i < sel.length; i++) {
>>       msgArray.push(tmpData.getValue(sel[i].row, 0));
>>     }
>>     alert(msgArray.join('\n'));
>>   }
>> });
>>
>> On Sunday, January 20, 2013 7:21:02 AM UTC-5, [email protected] wrote:
>>>
>>> There's a little bug there that I can't find. The exact code you posted..
>>>
>>> When you click on someone I get an alert, if I click on it on the 2nd 
>>> time (on the same line)  it's undefined, on the 3rd time (again on the same 
>>> line) it's back again and so on..
>>>
>>> Any idea why?
>>>
>>> On Friday, January 11, 2013 3:44:27 PM UTC+2, [email protected]:
>>>>
>>>> How can I add a select event to the StringFilter? (
>>>> https://code.google.com/apis/ajax/playground/?type=visualization#stringfilter_control
>>>> )
>>>> (like it's done here: 
>>>> https://code.google.com/apis/ajax/playground/?type=visualization#select_eventbut
>>>>  for a simple table).
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to