Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

The Problem

Using the Google Chart Tool it is possible to insert HTML values into the field values, however, I am not confident that this is good practice.

The method I have used is as follows:

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['Name', 'Height', 'Smokes','test'],
    ['Tong Ning mu', 174, true,'<input type="button" value="test" />'],
    ['Huang Ang fa', 523, false,'<input type="button" value="test" />'],
    ['Teng nu', 86, true,'<input type="button" value="test" />']
  ]);

  // Create and draw the visualization.
  visualization = new google.visualization.Table(document.getElementById('table'));
  visualization.draw(data, {
    allowHtml: true
  });
}

My Questions

  1. Are there any other better methods of achieving this?
  2. Are there ways of catching the events from these buttons, whilst also retrieving the id of the row that is receiving the event? In other words, how do I know which button has been clicked and for which row it represents?
share|improve this question
not sure of the google charts structure but a way to test is to assign a class to all of the buttons and then use a click event to check the parent and see what it is and go from there – Steve Nov 5 '12 at 12:23
@Steve This is exactly what I was going to do, but I see it as a dirty fix. It is not a very nice method as it relies on the parent having a unique feature, whether it be an id or content – Ben Carey Nov 5 '12 at 12:25

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.