Add / remove columns to javascript pivot grid

In this example we add a new column in final pivot view by simple array manipulation of ui.CM argument of pivotCM event.

Optionally we can also aggregates on the new column.

pivotCM: function (evt, ui) {
    //add new column.             
    ui.CM.push({
        title: 'New column',
        width: 120,
        dataIndx: 'new_col',
        summary: { type: 'sum'} 
    })                
}