Automatically Adding a Statistic to a Table

From Q
Jump to: navigation, search

Automatically adds the Average to any table (that has this as a possible Statistics in its cells).

if (table.availableStatistics.indexOf('Average') != -1) { // If Average is available on this table
    var stats = table.statistics; // Get the existing statistics on the table (selected by the context menu).
    if (stats.indexOf('Average') == -1) { // If Average is not already selected
        stats.push('Average'); // Add Average.
        table.statistics = stats; // Use our new list as the statistics.
    }
}

See also