我想通了!
我只需要移動我的位置:
//應用查詢語言語句。 query.setQuery('SELECT A');
out of sendAndDraw函數。
最後JS低於:
var isFirstTime = true;
var options = {'showRowNumber': true};
var data;
var queryInput;
// To see the data that this visualization uses, browse to
// http://spreadsheets.google.com/pub?key=rYQm6lTXPH8dHA6XGhJVFsA
var query = new google.visualization.Query(
'https://docs.google.com/a/umbc.edu/spreadsheet/ccc?key=0Akd-rqu1ZR70dDYxUEtFdGVadENqN09kT01pdklRbXc&pli=1#gid=0');
// Apply query language statement.
query.setQuery('SELECT A');
function sendAndDraw() {
// Send the query with a callback function.
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
data = response.getDataTable();
var table = new google.visualization.Table(document.getElementById('querytable'));
table.draw(data, {'showRowNumber': false});
if (isFirstTime) {
init();
}
}
function setQuery(queryString) {
// Query language examples configured with the UI
query.setQuery(queryString);
sendAndDraw();
queryInput.value = queryString;
}
google.setOnLoadCallback(sendAndDraw);
function init() {
isFirstTime = false;
(new google.visualization.Table(document.getElementById('table'))).draw(data, options);
queryInput = document.getElementById('display-query');
}
function setQueryFromUser() {
setQuery(queryInput.value);
}