views:

18

answers:

0

I have the following code to format a link in a data table.

function drawTable() {
    var query = new google.visualization.Query('http://somewhere.appspot.com/table');
    query.setQuery(queryString);
    query.send(handleQueryResponse);
}

function handleQueryResponse(response) {
    if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }

    var data = response.getDataTable();
    var table = new google.visualization.Table(document.getElementById('table_div'));
    var emailFormatter = new google.visualization.PatternFormat('<a href="mailto:{0}">{0}</a>');
    emailFormatter.format(data, [2]);

    table.draw(data, {allowHtml: true});
}

This works fine if all rows have e-mail addresses, how can I conditionally format empty e-mail addresses to not include the link. I still want the rows to show, but without an emtpy link.

Any help is appreciated.