The problem with this comes when deselecting rows. When you click an
already selected row a second time, it clears the selection, so
table.getSelection() returns null. There is no way to determine which row
was clicked on, so we don't know which to remove from the selection. You
can end route this by building the event listener in standard js. If
visual selection is all you need, then you can use CSS to highlight rows
(the viz API's built in classes provide easy access to this). If you need
to access data, then you'll need to do a bit more work to make sure the
rows selected in standard js match the ones you pull from the DataTable.
On Sunday, May 20, 2012 4:15:49 AM UTC-4, h wrote:
>
> There is no simple one line setting to make this happen but you can do the
> following.
> Store the list of selected rows in your javaScript and listen to every
> "select" event with something like this function
>
> var selectedRows = {};
> function handleSelection() {
> var selection = table.getSelection();
> var row = selection[0]['row'];
> selectedRows['row'] = true;
> var newSelection = [];
> for (var r in selectedRows) {
> newSelection.push({"row": r});
> }
> table.setSelection(newSelection);
> }
>
>
> On Fri, May 18, 2012 at 11:17 PM, clayadavis <[email protected]> wrote:
>
>> This seems like it would be easy, but my search skills seem to be
>> failing me. Is there a way to set the default behavior for a Table
>> Chart to emulate always having the 'ctrl' key pressed? In other words,
>> whenever I click on an unselected row, I want to add it to the
>> currently selected rows; clicking on an unselected row would then
>> unselect it, similar to checkboxes.
>>
>> The context for this is to select/unselect from the Table Chart items
>> which I want to compare in a Pie Chart.
>>
>> --
>> 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].
>> For more options, visit this group at
>> http://groups.google.com/group/google-visualization-api?hl=en.
>>
>>
>
--
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/-/1JYCWOMXAXkJ.
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.