2014-04-25 43 views
0

google.visualization.events指定有根據https://developers.google.com/chart/interactive/docs/gallery/table?hl=ja#Events頁面事件不google.visualization射擊

我試圖使用,可能不會得到完全正確的網頁事件。下面是我想

this.tableViz_ = new google.visualization.ChartWrapper({ 
    'chartType': 'Table', 
    'containerId': 'xyz', 
    'options': { 
     'allowHtml': true, 
     'cssClassNames': { 
     headerRow: 'header-row' 
     }, 
     'page': 'enable', 
     'pageSize': '100', 
     'sortAscending': false, 
     'sortColumn': 0 
    } 
    }); 

this.vizDashboard_ = new google.visualization.Dashboard(
     document.getElementById('xyz')); 

,我與

this.vizDashboard_.draw(data); 
    google.visualization.events.addListener(this.tableViz_, 'select', 
     goog.bind(this.test1, this)); 
    google.visualization.events.addListener(this.tableViz_, 'ready', 
     goog.bind(this.test2, this)); 
    google.visualization.events.addListener(this.tableViz_, 'page', 
     goog.bind(this.test3, this)); 

兩個選擇和準備工作正常後,該加入的聽衆,但是當我瀏覽到不同的頁面上表中它不觸發事件。我在這裏錯過了什麼?僅供參考,我們使用的是google.visualization API是1.1

回答

0

的ChartWrapper不聽可視化表它包裹的「頁面」事件,所以你必須直接設立處理程序上的表:

google.visualization.events.addListener(this.tableViz_, 'ready', function() { 
    google.visualization.events.addListener(this.tableViz_.getChart(), 'page', goog.bind(this.test3, this)); 
}); 
+0

我試過使用'this.tableViz_.getChart()',但是我發現getChart()還沒有被偵聽器觸發並且看到**無法讀取null的屬性'__eventTarget'** –

+0

如果你包裝它在像我的例子那樣的「ready」事件處理程序中,不應該發生這個錯誤。你能發表一個完整的例子來展示問題,或者鏈接到你的網頁,以便我可以測試它嗎? – asgallant

+0

這有效!謝謝。 –