Pivot2: Replace a value in a specific value in another column
Have this script to find and replace a specific cell value with another value:
function getWidgetDocumentObject(widget) {
if (prism.activeWidget == null)
return document.querySelector('[widgetid="' + widget.oid + '"]').querySelector('pivot2');
else
return document.querySelector('pivot2');
}
widget.on('ready', function(widget) {
docA = getWidgetDocumentObject(widget);
// Replace cell values
docA.querySelectorAll('.table-grid__cell').forEach((element) => {
if(element.querySelector('.table-grid__content').innerText == 'Spring Breeze') {
element.querySelector('.table-grid__content').innerText = 'Fall Leaves'
}
});
});
I would like to adapt this to search and replace values in a specific column. Any help is greatly appreciated.
Regards, Jim
Below script will replace cell values. Update the variable columnIndex with index of column you need.
widget.transformPivot( { type: ['member'] }, function setCellBackground(metadata, cell) { columnIndex = 2 if(metadata.colIndex == columnIndex) { cell.style = cell.style || {}; if(cell.content == 'Cannon') cell.content = 'Cannon - Updated Text' else if(cell.content == 'Hickman') cell.content = 'Hickman - Updated Text' } } );
Note : This script wont replace numbers from Values panel
-Hari