Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Aside from a "statechange" event handler, there is no way to tell when a control has changed. If you need to execute some code when a control changes, this is how you would do it:</p> <pre><code>google.visualization.events.addListener(control, 'statechange', function () { var state = control.getState(); // do something with the state, eg: var whereClauses = []; whereClauses.push('something1 = "' + state.selectedValues[0] + '"'); // ... }); </code></pre> <p>If, however, so you want to execute some code when any of the related controls change, then you can create a function and pass the function to the event handler:</p> <pre><code>function foo () { var state1 = control1.getState(); var state2 = control2.getState(); var whereClauses = []; whereClauses.push('something1 = "' + state1.selectedValues[0] + '"'); whereClauses.push('something2 = "' + state2.selectedValues[0] + '"'); // ... } // add event handlers to control1 and control2 using foo google.visualization.events.addListener(control1, 'statechange', foo); google.visualization.events.addListener(control2, 'statechange', foo); </code></pre> <p>If the function needs to know which control changed, then you can do something like this:</p> <pre><code>function foo (control, columnName) { var state = control.getState(); var whereClauses = []; whereClauses.push(columnName + ' = "' + state.selectedValues[0] + '"'); // ... } // add event handlers to control1 and control2 using foo google.visualization.events.addListener(control1, 'statechange', function () { foo(control1, 'something1'); }); google.visualization.events.addListener(control2, 'statechange', function () { foo(control2, 'something2'); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload