我正在尝试获取谷歌表格图表的选定值。当图表内容没有使用字符串过滤器进行过滤时,它会根据DataTable返回选定行的索引,但是当使用字符串筛选器过滤时,它不会返回正确的问题。
若要复制此问题,请执行以下代码1。
发布于 2014-09-04 17:46:00
这应该是可行的:
function tableSelectHandler(e){
var selectedItem = chart.getChart().getSelection()[0];
var true_selected = chart.getDataTable().getTableRowIndex(selectedItem.row)
alert(true_selected);
}getTableRowIndex将该行追溯到数据表
发布于 2014-09-05 03:25:03
展开juvian的答案,您应该在尝试访问数组中的任何元素之前测试选择长度,因为数组可能是空的(如果选择了多个行,则包含多个元素):
function tableSelectHandler(e){
var selection = chart.getChart().getSelection();
var dt = chart.getDataTable();
for (var i = 0; i < selection.length; i++) {
// colIndex is the index of the column you want to get data from
var value = dt.getValue(selection.row, colIndex);
}
}https://stackoverflow.com/questions/25658723
复制相似问题